Hello, everyone!
I recently had a problem when using variables. I am writing a script to load and quickly reset a player’s data, and then return it to the previous value. However, I cannot seem to find a way to store the original value without setting it to 0.
Consider this script:
player.data.item.Value = x
wait(0.01)
player.data.item.Value = 0
wait(0.01)
player.data.item.Value = x
This is what I am trying to achieve, however none of the solutions I have tried in studio have worked as they have overwritten the variable.
If I created a variable x to save the original number by connecting it to the item.Value, it would override at line 3 as it would receive the Changed signal and would remove the original value, making the data useless. Even if I created a variable in the actual function, it still would not save as it would (again) overwrite itself.
This question is incredibly basic, however I cannot find a solution that works after about 10 minutes of tinkering. How would I save a variable with a value that cannot be overwritten?
Thank you for reading this post.