It takes the currency if they are under the cost and they go negative. I don't know what I did wrong but everything works besides that.
01 | local PointsService = Game:GetService( "PointsService" ) |
02 | local ting = 0 |
03 | local Cost = 20000 |
04 |
05 |
06 | function onTouched(hit) |
07 |
08 | if ting = = 0 then |
09 | ting = 1 |
10 | print ( "It got past the tings" ) |
11 | check = hit.Parent:FindFirstChild( "Humanoid" ) |
12 |
13 | if check ~ = nil then |
14 | print ( "check is not nil" ) |
15 |
Your problem is with cash.Value > cash.Value - Cost
Let me explain:
Say the person has 10000 Cash and this costs 20000.
10000-20000 is -10000.
10000 > -10000, so the script still executes. I suggest you switch to cash.Value > Cost
So, if the person has 10000 Cash, 10000 is not greater than 20000 and it doesn't execute.