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

Script Wont Change Text to have text with the value?

Asked by 1 year ago

idk how to explain this but i want the script to change the number with to a value but the text stays the same, so its like it changes from Happiness = 100% to Happiness = 99%

local Number = game.ReplicatedStorage.Happiness
local Text = script.Parent

Number.Changed:Connect(function()
    Text.Text = "Happiness = " tostring(Number.Value)"%"
end)

1 answer

Log in to vote
2
Answered by 1 year ago
Edited 1 year ago

You need to use string concatenation to join them, you can do this by using two dots ..

local Number = game.ReplicatedStorage.Happiness
local Text = script.Parent

Number.Changed:Connect(function()
    Text.Text = "Happiness = "..tostring(Number.Value).."%"
end)
0
Alternative way is string.format() T3_MasterGamer 2189 — 1y
Ad

Answer this question