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

Gui re-appearing when player resets/dies?

Asked by 6 years ago

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)
0
nothing shows in output because you don't debug your code. SteamG00B 1633 — 6y
0
im confused DinozCreates 1070 — 6y
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. SteamG00B 1633 — 6y
0
we're changing the visibility of a gui from a server script? DinozCreates 1070 — 6y
View all comments (2 more)
0
also what steam said, what you're saying and doing dont make any sense DinozCreates 1070 — 6y
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. TheOnlySmarts 233 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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'.

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. Rheines 661 — 6y
0
can you not just destroy() it too? tonyv537 95 — 6y
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. TheOnlySmarts 233 — 6y
0
Thanks. this helped me fix my problem! alivemaeonman 14 — 4y
Ad
Log in to vote
0
Answered by
Rheines 661 Moderation Voter
6 years ago
Edited 6 years ago

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)

Answer this question