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

Gui re-appearing when player resets/dies?

So basically i'm trying to make the gui disappear when a player is dead and it doesn't come back until you join a new server, is there something wrong with my code? Nothing shows in the output.

game.Players.PlayerAdded:connect(function(plr)
    plr:WaitForChild("PlayerGui"):WaitForChild("trophy2019").Visible = true
end)

6 comments

0

nothing shows in output because you don't debug your code.

0

im confused

1

Hold up. You want the gui to disappear on death, but what you just showed us is to have a gui appear when a player is added... the exact opposite of what you are trying to accomplish. Also your title is asking for the opposite of what's in the description.

0

we're changing the visibility of a gui from a server script?

0

also what steam said, what you're saying and doing dont make any sense

0

Oof I know what he wants. Lemme just make an answer, crap. Rheines has already answered it... But did he answer it like how the author wants it?? Lemme see, hmm.

2 answers

✓ Accepted answer

Simply, if you want it so whenever the Player dies, that the GUI doesn't re-appear, there is a property in the ScreenGui properties where you can disable, ResetOnSpawn. Meaning it'll only show once.

https://gyazo.com/607e728f6cf092a325654fcf09f058c7

As you can see from opening that gyazo link, you'll be able to see where you can disable 'ResetOnSpawn'.

4 comments

0

Disabling ResetOnSpawn also works, but the GUI will still be inside the player's PlayerGui, only invisible if you set it to invisible when the player dies.

0

can you not just destroy() it too?

0

Yeah but doing it this way will mean, if the player needs it once more time, he can easily Enable it again through script.

0

Thanks. this helped me fix my problem!

What you want to do is to connect an event when the player is added into the game and when their character loads for the first time. After that, you can clone the GUI into the player's playergui.

--The player service.
local PlayerService = game:GetService("Players")

--This is the location of the GUI, you can put it where the server can access it.
local gui = --location

PlayerService.PlayerAdded:Connect(function(player)
	--Wait for the character to be added for the first time.
	--Use Wait() instead of :Connect here so it doesn't fire everytime the character spawns.
	player.CharacterAdded:Wait()
		local clone = gui:Clone()
		clone.Parent = player.PlayerGui
end)

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