Hello everyone. Quick question. I am currently testing my game with the “Local Server” feature on Studio. The script I am facing issues with is along the lines of:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if #game.Players:GetPlayers() == 2 then
print('enough players')
end
end)
end)
Now the output would currently look like this: enough players enough players
Is this due to latency issues due to the local server loading faster than the Roblox cloud servers or something wrong in the script format? Thanks!
I am not sure this would give me the desired result. The print message would be printed multiple times if there’s more people in the server. I only want this to happen just once when the server has reached 2 players. Even by changing the comparison operator, this would still output similar results as the one provided in the dummy script.
The double message happens because both players join first and then their characters are added causing the double fire. The message will also happen if one of the players respawn but im assuming that’s on purpose.
Thanks for your response. This basically confirms my initial theory. Your code also solves the output spam, but the local server still has some wonky stuff in it… although a bit less performant, at least it gets the job done. Will likely have to run my tests with an alt account on a cloud server.