Why is my value == 0 even though it's changed?
Asked by
6 years ago Edited 6 years ago
Ok, so I am working on a plugin and I had to make a script that assigns an id for each place.
My plugin includes a coregui so I inserted a script and a Number Value object to it, and I'm parenting my screen gui to game:GetService("CoreGui")
with the script and value inside. the script is generating a number for the id, after that i script:Destroy()
it. i also print the id just to make sure it's working, and it does print it.
Code in this script:
1 | local i = math.random( 1 , 1000000 ) |
3 | script.Parent.id.Value = tonumber ( tostring (math.random()):sub( 3 , 12 )) |
4 | print (script.Parent.id.Value) |
But after it's printed, and I try printing it again from somewhee else it prints 0.
https://gyazo.com/c9dad33fae4b62c18c52c786dacc6951
What is wrong?