The following works great in single player testing but not in multiplayer testing. I am getting the following error...
Error running Lua task: [A31B15D0BB8C19C5] NewScript:18: attempt to index a nil value (global 'other')
Line 18 is in the following where it says other = player. Do I need to set the player up a different way. Not sure I am following the issue.
gameState = "PLAYING"
-- This line is throwing an error in multiplayer only
other = player
if other:IsA("Player") then
Let me know if you need more context! Thanks for the time.
other is nil and
other is assigned to
player is nil. You have to define
Right, that makes total sense. What I am not tracking on is why it works for single player and NOT multiplayer testing. Shouldn't it be finding the player for each player that is active for each of the multiplayer players present?
That depends on the context of the script and what the rest of the code is doing.
How are you defining "player"? If you're in a server script, you need to define how that gets assigned.
You can do something like:
local players = Game.GetPlayers()
for _, player in ipairs(players) do
Events.BroadcastToPlayer(player, "endcourse", coursenum)
That should pull all active players in the game, then cycle through them and broadcast to each. I'm assuming you are broadcasting something different to each one and you're setting courseenum for each player. But if it's all the same data, you can do Events.BroadcastToAllPlayers().