takezo
takezo

Reputation: 91

How to change a Text of a TextLabel for a Attribute of the player

I need to change a TextLabel text to a Player Attribute Value but i dont know how to do this. I tried to make a code:

local player = game.Players.LocalPlayer
function ChangeTextMastery()
    script.Parent.Frame.CurrentMastery.Text = "Current Mastery - " .. tonumber(player:GetAttribute("Mastery"))
end

game.Players.PlayerAdded:Connect(ChangeTextMastery)

Upvotes: 0

Views: 98

Answers (2)

Google Donut
Google Donut

Reputation: 21

Yes you must do tostring() because it only accepts strings and not integers. If you want you can also write tostring(tonumber(Player:GetAttribute("Mastery"))) but I do not think it is needed

Upvotes: -1

Fabiano Madeira
Fabiano Madeira

Reputation: 28

try changing tonumber() to a tostring()

Upvotes: 0

Related Questions