Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Two warnings which don't seem to be normal?

--// 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?

1 comment

0

I'm assuming "Name" is a TextLabel.

1 answer

✓ Accepted answer

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.

1 comment

0

Oh alright.

This discussion is preserved as it was. New answers, comments, and votes are closed.