- numbers (-200, 50, 3.141, ...)
- strings ("hello", 'aaa', 'alligator', ...)
- nil
- booleans (true, false)
Are called primites, this means that whenever you assign these values into a variable, they are copied, modifying the new variable will no longer modify the previous variable in which these values were stored.
Value.Value is a number, that means whenever you put it a new variable (you put it into "value") it will create a new number that will be the same number, but no longer related to the previous variable. Whenever you modify "value" variable, you are modifying that one variable, not Value.Value.
Unlike Value.Value, the Value on the left is an Instance, these are not primitives meaning you can put it into variable and it won't get copied, that's what you need:
local value = script.Parent.Value
Next time you'd like to decrease the value, you have to write value.Value = ... instead.
Same applies to script.Parent.Text, this is string (text), it's primitive and is copied too, changing text variable will only change it, nothing else... and so do the same thing as with value, write script.Parent.Text = ... directly, you can shorten this by creating variable that will refer to script.Parent:
local label = script.Parent
label.Text = "Some text"
In the end, this is what you get:
local label = script.Parent
local value = label.Value
value.Value = 15
repeat
task.wait(1)
print(value.Value)
value.Value -= 1
label.Text = (value.Value .. " seconds until you can buy another item.")
until value.Value == 0
One thing i can suggest is to use task.wait over wait, there's not much difference, it's overall just more performance, also instead of writing x = x - 1 there is a shortcut x -= 1.
When you get better see "roblox for loops", maybe AlvinBlox.
When you get even better see "roblox task.wait delta time".
1 comment
its exploiters heaven to make clienside scripts