So I am trying to make an intermission script but for some reason, the countdown doesn't start. This is the server script.
game.Players.PlayerAdded:Connect(function(player) if Intermission.NewServer.Value == true then if Intermission.Timer:WaitForChild("LocalScript") then Intermission.NewServer.Value = false Intermission.Timer.Value = 30 Intermission.IntermissionStart:FireAllClients() end end end)
And the local script:
game.ReplicatedStorage.Intermission.IntermissionStart.OnClientEvent:Connect(function() for Timer = 30, 0, -1 do script.Parent.Timer.Value = script.Parent.Timer.Value - 1 wait(1) end end)
PlayerAdded
fires before the client even loads so the event is firing but the client and all the local scripts are not yet loaded thus they can't receive the signal.
Your solution would be instead of using PlayerAdded
function, create new RemoteEvent
and call it PlayerAdded
and on client, when your local script runs, fire signal from the remote event to server that the client has loaded. That way you can be sure that client is loaded. Something like this:
local Loaded = game:GetService('ReplicatedStorage').LoadedRemoteEvent -- your event ... some local code here Loaded:FireServer() --/Fires at the end of script and replaces PlayerAdded
--/Same event from the local script code local PlayerAdded = game:GetService('ReplicatedStorage').LoadedRemoteEvent PlayerAdded.OnServerEvent:Connect(function(Client) print(Client) -- prints TheReverseGaming ... your script would be here end