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

Why wont this concatenate?

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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
0
Oooh I am stupid to forget that, tahnks anyways!! chill22518 145 — 10y
0
No problem! (: Shrekerly 70 — 10y
Ad
Log in to vote
0
Answered by
DevChris 235 Moderation Voter
10 years ago

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.

Answer this question