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 4 years ago
1local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
2game.Players.PlayerAdded:Connect(function(player)
3    if player.Name == "ItzSulfonic" then
4        local clonedgui = billboardgui:Clone()
5        clonedgui.Parent = game.Workspace[player.Name].Head
6        clonedgui.TextLabel.Text = "Owner"
7        clonedgui.TextLabel.TextColor3 = Color3.fromRGB(231, 206, 12)
8    end
9end)

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 4 years ago
Edited 4 years ago

Try:

01local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
02game.Players.PlayerAdded:Connect(function(player)
03    if player.Name == "ItzSulfonic" then
04        local clonedgui = billboardgui:Clone()
05        local you = game.Workspace:WaitForChild("ItzSulfonic")
06        clonedgui.Parent = you.Head
07        clonedgui.TextLabel.Text = "Owner"
08        clonedgui.TextLabel.TextColor3 = Color3.fromRGB(231, 206, 12)
09    end
10end)
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 — 4y
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 — 4y
Ad

Answer this question