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

Why won't it change the text to the players name?

Asked by 5 years ago

Why won't it change the text to the players name?

Nametag is a BillboardGui

local Nametag = game:GetService("ReplicatedStorage"):WaitForChild("Nametag")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)

        print(player.Name)
        local ClonedNametag = Nametag:Clone()
        ClonedNametag.Parent = game.Workspace:WaitForChild(player.Name).Head
        ClonedNametag.Name.Text = player.Name
    end)
end)

Error - Workspace.Scripts.NameTag:9: attempt to index field 'Name' (a string value)

1 answer

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
5 years ago
Edited 5 years ago

I assume you have a TextLabel named "Name" in your billboardGui, Roblox is thinking that ClonedNametag.Name.Text is referencing the Name of the BillBoardGui, and not the TextLabel, now BillBoardGui's Name doesnt have a Text property which is why you got the error

You can either rename textlabel or reference the textlabel correctly

local Nametag = game:GetService("ReplicatedStorage"):WaitForChild("Nametag")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)

        print(player.Name)
        local ClonedNametag = Nametag:Clone()
        ClonedNametag.Parent = game.Workspace:WaitForChild(player.Name).Head
        ClonedNametag["Name"].Text = player.Name
    end)
end)
Ad

Answer this question