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

Why is Billboardgui making itself Adorneed to Player1's Head = false when Player2 comes in?

Asked by 4 years ago

I've had this problem for a while now, wanted to try and figure it out myself and I still have had no luck. When I click Play, the Gui works fine, but when I do Test with 2 players, Player2's Billboardgui is adorned to their head but Player1 is not adorned anymore, if that made sense, could anyone help me? Any help would be great! Thank you!

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerAddedEvent = game.ReplicatedStorage.PlayerAddedEvent
local Playername = nil
local Counter = 0
local Gui = game.Workspace.Dummy.BillboardGui
game.Players.PlayerAdded:Connect(function(plr)
        GuiClone = Instance.new("BillboardGui")
        NameLabel = Instance.new("TextLabel",GuiClone)
        GuiClone.Size = UDim2.new(3.5, 0,2, 0)
        GuiClone.ExtentsOffset = Vector3.new(0,3,0)
        NameLabel.Position = UDim2.new(0,0,0.5,0)
        NameLabel.Size = UDim2.new(1,0,0.5,0)
        NameLabel.Font = Enum.Font.GothamSemibold
        NameLabel.BackgroundTransparency = 1
        NameLabel.TextScaled = true
        GuiClone.Name = plr.Name
        NameLabel.Text = plr.Name
        plr.Team = game.Teams.Joining
        plr.RespawnLocation = game.Workspace.TeamSpawns.JoiningSpawn 
    plr.CharacterAdded:Connect(function(Char)
    local hum = Char:WaitForChild("Humanoid")
    print(Char)
    GuiClone.Parent = Char:WaitForChild("Head")
    GuiClone.Adornee = GuiClone.Parent
    if hum then
    hum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
    hum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
    game.ReplicatedStorage.PlayerAddedEvent:FireClient(plr)
        end
        end)

1 answer

Log in to vote
0
Answered by 4 years ago

Just had to change the CharacterAdded function to CharacterAdde:Wait(Char).

Ad

Answer this question