--// variables //-- local gui = game:GetService("ServerStorage"):WaitForChild("BillboardGui") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) if char.Head:FindFirstChild("BillboardGui") then print("BillboardGui is already inserted") else local clone = gui:Clone() clone.Frame.Name.Text = player.Name clone.Frame.Name.TextColor3 = Color3.RGB(100,0,0) clone.Parent = game.Workspace:WaitForChild(player.Name).Head end end) end)
(Without line 10 being commented) ServerScriptService.Script:10: attempt to index string with 'Text'
(With line 10 being commented) ServerScriptService.Script:11: attempt to call a nil value
With both 11 and 10 being commented, the gui does duplicate. Why does this happen?
Your problem is that your script thinks that "Name" is the property Name
inside the BillboardGui
. To fix this, simply rename your TextLabel
into "name" instead of "Name". Then, change all of the "Name"s in the script into "name"s:
--// variables //-- local gui = game:GetService("ServerStorage"):WaitForChild("BillboardGui") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) if char.Head:FindFirstChild("BillboardGui") then print("BillboardGui is already inserted") else local clone = gui:Clone() clone.Frame.name.Text = player.Name clone.Frame.name.TextColor3 = Color3.fromRGB(100,0,0) clone.Parent = game.Workspace:WaitForChild(player.Name).Head end end) end)
Hope this helps!
Edit: Another error - which is irrelevant to your question - can also be seen. You are saying Color3.RGB
on line 11, but this isn't a thing. You must use Color3.fromRGB
. I edited the script above.