Sure, the issue you have is a pretty common one in that you're looking at the value of the IntValue rather than subtracting from the actual reference itself. When you instantiate the variable "Cash", you create a new variable that is separate from the IntValue Cash, as workspace.Cash is an object in the workspace, while Cash = workspace.Cash.Value means it is simply an int variable, which would be no different than doing Cash = 10. Therefore, when you subtract 10 from Cash, everything is actually working perfectly, as Cash is indeed 10-10=0 now, but workspace.Cash was never modified. The fix for this is to simply reference workspace.Cash as local Cash, then compare Cash.Value and modify Cash.Value instead like so:
1 | script.Parent.ClickDetector.MouseClick:connect( function () |
2 | local Cash = workspace.Cash |
3 | if Cash.Value > = 10 then |
4 | Cash.Value = Cash.Value - 10 |