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

How do you set a function to run for every respawn except the first?

I have a script here that relies on the CharacterAdded function to make a gui appear whenever the character respawns so they can choose their spawn point, but I don't want it to run when they first join the game, only every respawn after. Here is the code. How do I edit this to make it so that it doesn't run when they first join? EDIT: It appears this function doesn't even work by itself. What am I doing wrong?

function CharacterAdded(player)
	script.Parent.Parent.Visible = true
function Click(mouse)
	if game.Workspace.ERDSObj.Marker.Color == player.TeamColor then
		player.Character.Torso.CFrame = CFrame.new(Vector3.new())
		script.Parent.Parent.Visible = false
	end
end
end

script.Parent.MouseButton1Down:connect(Click)

1 answer

✓ Accepted answer

Go for a simple debounce,

local debounce = false
function CharacterAdded(player)
    if debounce == true then
        script.Parent.Parent.Visible = true
    else
        debounce = true
end

This shouldn't work the first time but will work the second. However if more players join it will make the GUI show so you would have to make this a local script and connect is with events. But you can make a GUI show with local scripts so I hope this helped!

4 comments

0

I think you used a local script too so this should work (:

0

While I'm certain this should work, it strangely isn't...

0

I did something like this before, but no matter what I do, this gui won't show up. This is what I needed. I'll need a new question for the gui showing.

0

That is very strange.... If this doesn't work then you might just want to connect the function with a died even or something. Good luck to you though!

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