Hi! I have a gui thats given to the player when they die. The gui is a basic play button that when pressed (should) respawn the player and hide the gui. However, the button does nothing when pressed? Can someone please help ASAP! Thank You!
Script In Gui:
local player = game.Players.LocalPlayer local playbutton = script.Parent.ClearFrame.PlayButton game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(character) playbutton.MouseButton1Click:Connect(function() script.Parent.ClearFrame.Visible = false game.ReplicatedStorage.CharLoad:FireServer(player) end) end) end)
Script In ServerScriptService:
game.ReplicatedStorage.CharReLoad.OnServerEvent:Connect(function(player) player:LoadCharacter() end)
The player added event won't fire for the local player because the player object is being created before the script, it will only fire for future players that join the server.
I'm not quite sure why you're using a PlayerAdded event here... You already have a reference to the local player, so it isn't really necessary, just use the CharacterAdded event on the variable where you have the local player referenced.
Also, ScreenGuis have a property named ResetOnSpawn which will delete and clone itself back into the players' PlayerGui after they respawn.