Hello, I've been trying to make a menu that displays when the player dies. When the player dies a menu will display with a respawn button but nothing happens when they press the button. Also, there is no error in the output. My code:
LOCAL Script 1(MenuOpener)
local Players = game:GetService("Players")
local menu = script.Parent -- Gets the Menu
local player = Players.LocalPlayer
local character = player.Character
character:WaitForChild("Humanoid").Died:Connect(function()
menu.Visible = true
end)
Script 2(RespawnHandler) l~~~~~~~~~~~~~~~~~ local RespawnButton = script.parent game.Players.CharacterAutoLoads = false
local menu = script.Parent local Players = game:GetService("Players") local player = Players.LocalPlayer RespawnButton.MouseButton1Click:Connect(function() --Below does not work! if player then menu.Visible = false player:LoadCharacter() end end)

14 comments
Sadly, this doesn't work. My script isn't a LocalScript because i need to use player:LoadCharacter() Which can't be used in a LocalScript if I'm correct
Sadly, this doesn't work. My script isn't a LocalScript because i need to use
player:LoadCharacter()Which can't be used in a LocalScript if I'm correctunfortunely, you have to use a local script to manage the gui closing.
Here is an image of my Explorer https://cdn.discordapp.com/attachments/756819047311736842/848450737448943697/Screenshot_2021-05-30_163916.jpg
i edited my answer
alright, thanks for sharing the explorer with me, I can help better now
Oh dam. So how would i manage to respawn the player after they've clicked the button?
hold on, i'm editing my answer one more time
alright, i'm done.
Wow, thanks man this worked! It takes like two seconds to actually close the GUI is there a reason or fix for this?
you meant after you click respawn it takes 2 seconds to close?
well there isn't really a reason, as there isn't a wait(2) anywhere along the script. Also please accept the solution since it worked for you!
You can look in Players.RespawnTime. Maybe its set 2 seconds there
Oh it is, is there a way to stop it from doing that? If i set it to zero it will just keep doing it every second.