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

How to add a variable to the text?

I want to add a variable to the text button.

local variable = Instance.new("IntValue")
variable.Parent = game.Players.LocalPlayer
variable.Value = 0

local block = Instance.new("TextButton")
block.Text = "Block LV. 1: variable.Value"

Is this work? Or I must write it differently.

1 answer

✓ Accepted answer

You did not assign the textbox a parent, it will not work, also don't put values in the player put them somewhere organized like a folder inside the player. I suggest creating the text button first, like this.

local block = Instance.new("TextButton")
block.Text = "Block LV. 1:"..variable.Value--this will set the text to the actual value and not the string "variable.Value"

local variable = Instance.new("IntValue")
variable.Parent = block
variable.Value = 0

I hope this helps :3

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