But I'm trying to award players with coins, wins, and Player Points on a win (when they touch a button). However, it gives multiple of each to them whenever they win. How can I fix this? This is what I have now:
button.Touched:connect(function(part)
debounce = false
if not debounce then
debounce =true
local playa=game.Players:FindFirstChild(part.Parent.Name);
if playa and playa.isIn.Value then
if #_G.stats==0 then
playa:SaveNumber("wins",playa:LoadNumber("wins")+1);
playa.leaderstats.Wins.Value=playa:LoadNumber("wins");
if game:GetService("GamePassService"):PlayerHasPass(playa,167871575) then
playa.leaderstats.Coins.Value=playa.leaderstats.Coins.Value+200
else
playa.leaderstats.Coins.Value=playa.leaderstats.Coins.Value+100
end
playa.EXP.Value=playa.EXP.Value+50
if game:GetService("GamePassService"):PlayerHasPass(playa,167871800) then
pts:AwardPoints(playa.userId,1)
else
pts:AwardPoints(playa.userId,70)
pts:AwardPoints(26097803,30)
end
end
table.insert(_G.stats,{name=playa.Name,k=tick()-startTime,team=BrickColor.new("Bright blue")});
playa.leaderstats.Pos.Value=numberDisp(#_G.stats);
playa.isIn.Value=false;
playa.TeamColor=waiting.TeamColor;
playa.Character.Torso.CFrame = Workspace.Floor.CFrame--(0,6,0)
debounce=false
end
end
end) |