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

Why does my BillboardGui re-appear after the {Player} resets?

Asked by 4 years ago

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;

local function onNameEvent()
    playerWS.Head:FindFirstChild("BillboardGui").Enabled = false

    if humanoid:GetState() == Enum.HumanoidStateType.Dead then
        player.Character:WaitForChild("HumanoidRootPart")
        playerWS.Head:FindFirstChild("BillboardGui"):Destroy()
    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.

0
Are you trying to have the BillboardGui in there until they die then disappear? What does your code look like for putting the BillboardGui into the player? MrLonely1221 701 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

        local playerWS = character:FindFirstChild("Head")
        local localPlayer = client.Character

        local billboardGUI = Instance.new("BillboardGui", playerWS)
        local textLabel = Instance.new("TextLabel", billboardGUI)
            textLabel.Text = character.Name


            billboardGUI.ExtentsOffset = Vector3.new(0, 3, 0)
            billboardGUI.Size = UDim2.new(1,1, 1,1)
            billboardGUI.ResetOnSpawn = false

            textLabel.Font = "SourceSansLight"
            textLabel.Size = UDim2.new(5,0, 1,1)
            textLabel.TextStrokeColor3 = Color3.new(0, 0, 0)
            textLabel.TextStrokeTransparency = 0
            textLabel.TextColor3 = Color3.new(255, 255, 255)
            textLabel.TextScaled = true
            textLabel.BackgroundTransparency = 1
            textLabel.Position = UDim2.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.

0
Let me guess, you're destroying it on the Client and not the server huh. MrLonely1221 701 — 4y
Ad
Log in to vote
0
Answered by
Slatryte 104
4 years ago

Answer

I believe you are accidentally using s client-side property of the object. Instead, I recommend this:

local function onNameEvent()
playerWS.Head:FindFirstChild("BillboardGui").Enabled = false

if humanoid:GetState() == Enum.HumanoidStateType.Dead then
    player.Character:WaitForChild("HumanoidRootPart")
    playerWS.Head:FindFirstChild("BillboardGui").Enabled = false
 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.

What is the Enabled property?

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.

Conclusion

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.

Answer this question