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

How to prevent Health billboard gui disappear after respawn?

Asked by 8 years ago
01game.Players.ChildAdded:connect(function(player)
02    player.CharacterAdded:connect(function(char)
03        local plyrGuiH = Instance.new("BillboardGui")
04        plyrGuiH.Name = "HealthOverlay"
05        plyrGuiH.Parent = char.Head
06        plyrGuiH.Adornee = char.Head
07        plyrGuiH.Size = UDim2.new (1,0,1,0,0,0)
08        plyrGuiH.StudsOffset = Vector3.new (0,1.2,0)
09        --plyrGuiH.PlayerToHideFrom = player
10 
11        local frame = Instance.new("Frame")
12        frame.Parent = plyrGuiH
13        frame.Size = UDim2.new (0,180,0,10)
14        frame.BackgroundColor3 = Color3.fromRGB (9, 33, 49)
15 
View all 38 lines...

When enter the game, the billboard is there , but after reset the character it is gone.

0
Suggest parenting it inside of PlayerGui, setting it to not reset on respawn, and adornee it to the head as you already do. RubenKan 3615 — 8y
0
Still disappear :c xiFrosty 13 — 8y
0
You gotta set the adornee again when a new character gets added, since the old Head is gone. RubenKan 3615 — 8y

2 answers

Log in to vote
0
Answered by
systack 123
8 years ago

You were setting the script's parent to the gui object, so when the player resets, the script is destroyed, severing the connections of the listeners in it.

I also recommend you use a serverscript and put it in ServerScriptService instead.

(Also if you need help centering the GUI and locking it's size, let me know)

01game.Players.PlayerAdded:connect(function(player)
02    player.CharacterAdded:connect(function(char)
03        local plyrGuiH = Instance.new("BillboardGui")
04        plyrGuiH.Name = "HealthOverlay"
05        plyrGuiH.Parent = char.Head
06        plyrGuiH.Adornee = char.Head
07        plyrGuiH.Size = UDim2.new (1,0,1,0,0,0)
08        plyrGuiH.StudsOffset = Vector3.new (0,1.2,0)
09        --plyrGuiH.PlayerToHideFrom = player
10 
11        local frame = Instance.new("Frame")
12        frame.Parent = plyrGuiH
13        frame.Size = UDim2.new (0,180,0,10)
14        frame.BackgroundColor3 = Color3.fromRGB (9, 33, 49)
15 
View all 34 lines...
0
Ohh I see!! Thank you very muchh!! I need your help with the glitching part of the gui too and I think I do need your help how to center the Gui and locking it's size. It would be nice of you to help me with that x3 I'm still learning scripting. :D xiFrosty 13 — 8y
Ad
Log in to vote
0
Answered by
Admin8483 -21
8 years ago

Just go to the ScreenGui, click it, and make the ResetOnSpawn property false. I used to have the same problem.

Answer this question