Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Djinous 45
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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!

0
I think you used a local script too so this should work (: User#11440 120 — 8y
0
While I'm certain this should work, it strangely isn't... Djinous 45 — 8y
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. Djinous 45 — 8y
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! User#11440 120 — 8y
Ad

Answer this question