I've got a tool, that when activated, will change a value to itself minus one as long as the current value is above 0. Here's the important part of the script:
local matches = game.Lighting.Hardcore.matchesleft.Value
Tool.Activated:connect(function()
if matches > 0 then
print("You have matches")
matches = matches - 1
end
end)
Alright, so, a bit of explaining --
- The print DOES activate correctly.
- The variable "matches" refers to an integer variable (I've also tried number to no avail)
- I've tried removing "Value" from the variable, and hand placing it in the formula.
- This is in a regular script, however everything else registers so I don't think it's an issue.
- I can verify this isn't an issue, since I have now tried it.
- I can change the value manually in game, to make sure nothing else is changing it back.
If you have any ideas as to why this isn't working, please let me know -- I see no reason why it shouldn't.
Edit: The moral here is DON'T get greedy with variable shortcuts!

4 comments
I just tried it in a local script as well (probably should have already), and it's still printing correctly, but the value just won't change.
Just an idea, but you may want to try the code in a LocalScript.
I agree with RedCombee, I'd try a LocalScript. Also, I would just get rid of .Value in the matches variable and put it into the anonymous function manually. I don't think the Value property would change if it's sets as a variable.
Strange, I just tried the .Value thing again, and it's now functioning. I'm always getting caught on trying to take too large a shortcut on variables. Feel free to post an "answer" and I'll accept it.