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

Two warnings which don't seem to be normal?

Asked by
Ieowyyn 69
4 years ago
Edited 4 years ago
--// 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?

0
I'm assuming "Name" is a TextLabel. DesertusX 435 — 4y

1 answer

Log in to vote
1
Answered by
DesertusX 435 Moderation Voter
4 years ago
Edited 4 years ago

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.

0
Oh alright. Ieowyyn 69 — 4y
Ad

Answer this question