If the LeaderBoard is working then try this: A shop type thing.
Shop thing
local debounce = false
local price = 5
script.Parent.Touched:connect(function(part)
local plyr = game:GetPlayerFromCharacter(part.Parent)
local stat = plyr:FindFirstChild("leaderstats")
local cash = stat:FindFirstChild("Cash")
if not debounce and plyr and stat and cash and cash.Value >= price then
debounce = true
cash.Value = stat.Cash.Value-price
script.Parent:Destroy()
wait(5)
debounce = false
end
end)
Cash Giver
local debounce = false
local reward = 1000
script.Parent.Touched:connect(function(part)
local plyr = game:GetPlayerFromCharacter(part.Parent)
local stat = plyr:FindFirstChild("leaderstats")
local cash = stat:FindFirstChild("Cash")
if not debounce and plyr and stat and cash then
debounce = true
cash.Value = stat.Cash.Value+reward
wait(5)
debounce = false
end
end)
Leaderstats
If It doesn't show "Cash" in the leader stats do this.
local Cash = Instance.new("IntValue", stat)
Cash.Name = "Cash"
Cash.Value = 0
You were too vague, sorry If I didn't do what you wanted.
5 comments
Just sayin, but most people don't want to go through entire scripts like this. If you can, narrow it down a little bit so it's easier for us to work with.
Just please cut out a part, where the error is!
Is that what you mean?
No, lol, we're saying that u need to leave part of the script, but only the part where you think the error is
I have no idea where the error is at all. I have no idea why the cash wont work with the purchases even tho its working with the leaderboard.