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

How could you make a int value show up in a TextLabel?

Asked by
Fako16 13
5 years ago

https://gyazo.com/ef379282dc78f734e5f8064e0af4e862 Here's a example, I want the 0 to be a IntValue, lets say when someone hits a tree the value goes up by 1, how could I make it show up in the GUI? Is there a way to change the Text via IntValues?

Thanks for any help!

0
by the way, you need to copy paste the link since the link cant be opened via clicking on it, dont know why, sorry :D Fako16 13 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Basically from what I understood you want a script that increases the value of an IntValue by one every time you touch a part (in this case a tree). All you have to do is make a function that increases the value of the IntValue by one and has a loop that changes the text of the Gui to the value of the IntValue.

Example:

local treePart = workspace.TreePart -- Whatever this might be
local textLabel = ScreenGui.TextLabel -- Whatever this textlabel is
local intValue = workspace.IntValue -- Whatever this intvalue is

treePart.Touched:connect(function()
    intValue.Value = intValue.Value + 1 -- increases the value of the int value by 1
end)


while wait() do
    textLabel.Text = tostring(intValue.Value) -- changes the text of the TextLabel continuously
end

I hope this helps!

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Hello sir, from what i understand you are trying to update the text of the UI every time your integer value changes right? In this case you will need "value.Changed" and function for example:

local val = --your int value here
local text = --your TextLabel.Text here
local function updateText() 
    text = ""..val
end
value.Changed:Connect(updateText) -- this line will run the function every time your value changes. 

Warning! this is just example you will probably need to edit the script to make it work for your game :)

0
but text cant be set as an int value? Fako16 13 — 5y
0
It cant, but you can set int value as text :D theswagboy0813 -14 — 5y

Answer this question