Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Simple function failing to get past a 6 second wait?

I'm trying to change the team of a player, wait a time, then change it back(when a button on a GUI is clicked), but after print-debugging, I've seen that it's not getting past the wait function - it kills the player, puts them into the "Dark stone grey" team, then stops. This is a little frustrating, as I see no reason this would happen. Thank you for all help. Script below:

local button = script.Parent

button.MouseButton1Down:connect(function()
	local pToKill = button.Parent.pNameBox.Text
	local p = game.Players:FindFirstChild(pToKill)
	local char = p.Character
	local pTeam = p.TeamColor
	print(pTeam)
	p.TeamColor = BrickColor.new("Dark stone grey")
	char.Humanoid.Health = 0
	wait(6)
	game.Players:FindFirstChild(pToKill).TeamColor = BrickColor.new(pTeam)
	char.Humanoid.Health = 0
	print(pTeam)


end)

1 answer

✓ Accepted answer

ScreenGuis normally completely reset when the player respawns. So, your script never completes after 6 seconds. To disable this, set your ScreenGui's "ResetOnSpawn" property to false.

1 comment

0

I'm an idiot. Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.