I have a regular script in StarterGui that checks each time the player respawns if they are on the prisoner team (Royal purple team). Then it fires a custom function called timer that starts a for loop to countdown the amount of seconds the player is in the prison before their team is changed back and they are respawned.
The script works perfectly in any testing I do in Studio, yet doesn't work in a regular game. I've tried several fixes and none of worked any help would be appreciated.
function timer()
for i=120,0,-1 do
if i == 1 then
script.Parent.PrisonGUI.PrisonerFrame.TimeLabel.Text = "TIME REMAINING: "..i.." second"
wait(1)
elseif i == 0 then
script.Parent.PrisonGUI.PrisonerFrame.TimeLabel.Text = "RESPAWNING"
script.Parent.Parent.TeamColor = BrickColor.new("New Yeller")
script.Parent.PrisonGUI.PrisonerFrame.Visible = false
game.Players:FindFirstChild(script.Parent.Parent.Name):LoadCharacter()
else
script.Parent.PrisonGUI.PrisonerFrame.TimeLabel.Text = "TIME REMAINING: "..i.." seconds"
script.Parent.Parent.TeamColor = BrickColor.new("Royal purple")
wait(1)
end
end
end
if script.Parent.Parent.TeamColor == BrickColor.new("Royal purple") then
script.Parent:WaitForChild("Menu").Frame.Visible = false
script.Parent:WaitForChild("PrisonGUI").PrisonerFrame.Visible = true
if script.Parent.PrisonGUI.PrisonerFrame.TimeLabel.Text == "TIME REMAINING:" or script.Parent.PrisonGUI.PrisonerFrame.TimeLabel.Text == "RESPAWNING" then
timer()
else
print("hi")
end
else
--print("no")
end
GUI Directories if you need them: Screenshot

1 comment
Don't put serverScripts in StarterGui, that is likely the source of your problem