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

How do i fix player is not a valid member of Workspace?

Asked by 3 years ago
local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
game.Players.PlayerAdded:Connect(function(player)
    if player.Name == "ItzSulfonic" then
        local clonedgui = billboardgui:Clone()
        clonedgui.Parent = game.Workspace[player.Name].Head
        clonedgui.TextLabel.Text = "Owner"
        clonedgui.TextLabel.TextColor3 = Color3.fromRGB(231, 206, 12)
    end
end)

Im trying to make it so ingame i have the word "Owner" above my head only but when i go to test i get this error

16:10:54.665 - ItzSulfonic is not a valid member of Workspace "Workspace"

1 answer

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

Try:

local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
game.Players.PlayerAdded:Connect(function(player)
    if player.Name == "ItzSulfonic" then
        local clonedgui = billboardgui:Clone()
        local you = game.Workspace:WaitForChild("ItzSulfonic") 
        clonedgui.Parent = you.Head
        clonedgui.TextLabel.Text = "Owner"
        clonedgui.TextLabel.TextColor3 = Color3.fromRGB(231, 206, 12)
    end
end)
0
Yes this worked perfectly only thing is there's this in output but other than that thanks for the help 18:48:58.302 - Infinite yield possible on 'Workspace:WaitForChild("ItzSulfonic")' ItzSulfonic 61 — 3y
0
Since you are using WaitForChild, if the waitforchild doesn't find what it's waiting for, for the first 5 seconds, the output will display a Infinitie Yield warning, nothing to worry about if your script ends up finding what it's waiting for. wizz_zz 3 — 3y
Ad

Answer this question