Hi people, I am actually doing a game with a LobbyServer and a GameServer. In the LobbyServer, there is a looped script. When a player connect to the game, it start loop. But the problem is that when a second player connect, it begin one more time the loop. I tried to correct that with a value which turn true when a player connect and the loop doesn't loop one more time. And now the problem is when a second player connect, the time goes 2 more time faster (it seem like the t = t-1 goes 2 time). Can someone help me ? Thanks for answer :D Here is the code.
local Looped = game.Workspace.Looped
Looped.Value = false
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function()
if Looped.Value == false then
Looped.Value = true
StartGame()
else
Looped.Value = false
end
end)
function StartGame()
local s = script.Stat
while true do
t = 30
repeat
t = t-1
s.Value = "The experience will start in "..t.." second(s)"
wait(1)
until t == 0
s.Value = "Teleporting players"
wait(0.5)
s.Value = "Teleporting players."
wait(0.5)
s.Value = "Teleporting players.."
wait(0.5)
s.Value = "Teleporting players..."
wait(0.5)
TeleportPlayers()
ElevatorMoving()
end
end

1 comment
I already used a denounce and didn’t work