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)
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!