Hello scriptinghelpers, I'm here to ask a question regarding why my BillboardGui seems to re-appear after the {Player} resets, dies, or something along those lines; I have already tried using ResetOnSpawn to no avail, here's the current piece I need help with;
1 | local function onNameEvent() |
2 | playerWS.Head:FindFirstChild( "BillboardGui" ).Enabled = false |
3 |
4 | if humanoid:GetState() = = Enum.HumanoidStateType.Dead then |
5 | player.Character:WaitForChild( "HumanoidRootPart" ) |
6 | playerWS.Head:FindFirstChild( "BillboardGui" ):Destroy() |
7 | end |
Could you tell me why the BillboardGui re-appears inside of Workspace and doesn't get destroyed after the {Player} respawns? Thank you for any and all help.
Thanks for the response @MrLonely1221, I suppose I should've been more specific; the BillboardGui will stay above the {Player}'s head indefinitely for other users but the BillboardGui will never show up on the {Player}'s screen; a name-tag system, of sort.
Here is the code for inserting the BillboardGui into the {Player}.
01 | local playerWS = character:FindFirstChild( "Head" ) |
02 | local localPlayer = client.Character |
03 |
04 | local billboardGUI = Instance.new( "BillboardGui" , playerWS) |
05 | local textLabel = Instance.new( "TextLabel" , billboardGUI) |
06 | textLabel.Text = character.Name |
07 |
08 |
09 | billboardGUI.ExtentsOffset = Vector 3. new( 0 , 3 , 0 ) |
10 | billboardGUI.Size = UDim 2. new( 1 , 1 , 1 , 1 ) |
11 | billboardGUI.ResetOnSpawn = false |
12 |
13 | textLabel.Font = "SourceSansLight" |
14 | textLabel.Size = UDim 2. new( 5 , 0 , 1 , 1 ) |
15 | textLabel.TextStrokeColor 3 = Color 3. new( 0 , 0 , 0 ) |
16 | textLabel.TextStrokeTransparency = 0 |
17 | textLabel.TextColor 3 = Color 3. new( 255 , 255 , 255 ) |
18 | textLabel.TextScaled = true |
19 | textLabel.BackgroundTransparency = 1 |
20 | textLabel.Position = UDim 2. new(- 2 , 0 , - 0.5 , 0 ) |
Everything works just as I'd hope for it to.. until the {Player} resets and it ends up appearing to the {Player}, rather than only other users.
I believe you are accidentally using s client-side property of the object. Instead, I recommend this:
1 | local function onNameEvent() |
2 | playerWS.Head:FindFirstChild( "BillboardGui" ).Enabled = false |
3 |
4 | if humanoid:GetState() = = Enum.HumanoidStateType.Dead then |
5 | player.Character:WaitForChild( "HumanoidRootPart" ) |
6 | playerWS.Head:FindFirstChild( "BillboardGui" ).Enabled = false |
7 | end |
I have had some experience with the .Enabled
function in which I wanted it to be client-side, but it was server-side, and that script was a failure, and from that, I have learnt that it's a server-side property. Thankfully, I can tell this information to you.
The Enabled
property is used to disable and enable a GUI and whatnot. I have recently found it is server-side, as I mentioned before, and it should work much better than the :Destroyed
function.
I really hope this script works, and if not, I also have my ways to go. Not everyone is perfect, so if I have made any mistakes in this, please do not be rude.