Hello! I have a script that checks when a player stops doing something. I have it all working but I want this while wait script to stop after the timer is done
Script:
game.ReplicatedStorage.RemoteEvents.PlayersDone.OnServerEvent:Connect(function()
ScreenGui.Start.Start.FinishedButton.Visible = false
ScreenGui.Start.Start.Time.Visible = false
end)
game.ReplicatedStorage.RemoteEvents.GameStart.OnServerEvent:Connect(function()
while wait(1) do
ScreenGui.GameScript.Time.Value = ScreenGui.GameScript.Time.Value - 1
ScreenGui.Start.Start.Time.Text = ScreenGui.GameScript.Time.Value
if ScreenGui.GameScript.Time == 0 then
print("Time finished.")
end
end
end)
localscript:
while wait(0.1) do
if script.PlayersFinished.Value == PlayerCount then
print("all players have finished their sentences.")
game.ReplicatedStorage.RemoteEvents.PlayersDone:FireServer()
else
print("All Players have not finished their sentences.")
end
if ScreenGui.GameScript.Time == 0 then
print("Time finished.")
game.ReplicatedStorage.RemoteEvents.PlayersDone:FireServer()
end
end