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.
local PointsService = Game:GetService("PointsService")
local ting = 0
local Cost = 20000
function onTouched(hit)
if ting == 0 then
ting = 1
print("It got past the tings")
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
print("check is not nil")
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
print("stats is not nil")
local cash = stats:findFirstChild("Cash")
if cash.Value > cash.Value - Cost then
print("Value of cash is fine")
cash.Value = cash.Value - Cost
print("Made the sale")
PointsService:AwardPoints(user.userId, 1)
print("Awarded points")
wait(5)
end
end
end
ting = 0
print("Ting back to 0")
end
end
script.Parent.Touched:connect(onTouched)

4 comments
Did this work?
Lol, I don't know why i didn't see this in the first place.. lol thanks, it should work now XD
You're welcome.
Remember it should really be >=, or else I can't buy a $1 thing with $1!