I know that the 'Hint' class is deprecated, but I wanted to test making a countdown.
local Hint = Instance.new("Hint") Hint.Parent = workspace local Text = Hint.Text Text = "5" while Text > 0 do wait(1) Text = Text-1 end -- This code doesn't work, I even tried converting to numbers and to strings
I noticed that I could fix it from instead of using a variable for Text, I edit it directly, why is this?
local Hint = Instance.new("Hint") Hint.Parent = workspace workspace.Message.Text = 5 while tonumber(workspace.Message.Text) > 0 do wait(1) workspace.Message.Text = workspace.Message.Text -1 print(workspace.Message.Text) end --This code does work
You cannot change a property by referencing it from a variable because when you assign a variable to a property, the variable becomes a static representation of the property's value at the time the script executed the definition.
So, when you go to set the variable again, you are just changing the variable.. not the property.
This is why you must always index the Property from it's parent to actually change it.
--Example local part = workspace.Part; local color = part.BrickColor print(color); --> Medium stone grey color = BrickColor.new("Really red"); print(part.BrickColor); --> Medium stone grey print(color); --> Really red