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

Why wont this concatenate?

This is the error that comes when I run the script: Players.Player.PlayerGui.ScreenGui.TextBox.Script:5: attempt to concatenate global 'Power' (a userdata value)

this script is a child of a textbox.

Player = script.Parent.Parent.Parent.Parent
Char = Player.Character
Power = Player:WaitForChild("Power")

script.Parent.Text = "Energy: " .. Power

2 answers

✓ Accepted answer

I believe it is because setting the text of anything requires a string, and it can't find one from that. If it is a StringValue, do this:

script.Parent.Text = "Energy: " .. Power.Value

Otherwise if it is another Gui, do this:

script.Parent.Text = "Energy: " .. Power.Text

2 comments

0

Oooh I am stupid to forget that, tahnks anyways!!

0

No problem! (:

Please use LocalScripts for GUI and anything that is for the player only. This will fix it:

local player = game.Players.LocalPlayer -- You can get the player easily in localscripts
local power = player:WaitForChild("Power")

script.Parent.Text = power.Value -- Power itself is not a value (it's an object) therefore we need to set it to a property of the object.

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