Hi! I’m having a bit of trouble with my script. I’m fairly new to scripting, so sorry if it’s something small that I missed.
The print() function works as expected, but, it doesn’t update the text on the UI. No errors in the output either. Any help?
For future reference, it’s bad practice to space everything out in a script like that. You should also use tabs when using things like repeat and function
Ex.)
local TitleScreen = script.Parent
local count = 0 -- Initialize a new variable count that equals 0
repeat
count = count + 1
wait(0.5)
TitleScreen.LoadingFrame.Loading.Text = count
until count == 100
You also can’t set variables (in your case count) to InstanceValue.Value, as this will just set the variable one time to equal the number, and will not update with that property.
Ex.)
local variable0 = workspace.NumberValue.Value
local variable1 = workspace.NumberValue
variable0 = variable0 + 1
print(workspace.NumberValue.Value) -- Will print 0, not 1.
variable1.Value = variable1.Value + 1
print(workspace.NumberValue.Value) -- Will update the value and print 1!
However, you can avoid this altogether by just using a local variable initialized inside of the script as you saw above. InstanceValues are insecure, and can be easily changed and abused by exploiters. Avoid them whenever possible!