Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

Why does this award multiple items?

Asked by 10 years ago

01 debounce = false 02

03 script.Parent.MouseEnter:connect(function(enter) 04 script.Parent.BorderSizePixel = 3 05 script.Parent.MouseButton1Click:connect(function(onClick) 06 for i, player in pairs(game.Players:GetChildren()) do 07 if player.Points.Value >= 100 then 08 player.Points.Value = player.Points.Value - 100 09 if debounce == false then 10 debounce = true 11 local ks = game:GetService("ReplicatedStorage").Swords.KnightsSword 12 ks:Clone().Parent = player.Backpack 13 ks:Clone().Parent = player.StarterGear 14 debounce = false 15 end 16 end 17 end 18 end) 19 end) I have tried many different ways to stop this but nothing works. I have it set to if the player has 100 or more points then give them an item, but it dosent just give them the item and takes 100 away, sometimes it gives you 2 or 3 of the item and charging 200, or 300. Is there a way to prevent that so it the sword is only awarded ONCE and they cant pruchase another for 10 seconds.

1
Put it in a code block please. SlickPwner 534 — 10y

1 answer

Log in to vote
0
Answered by
parkderp1 105
10 years ago

This is the srcipt in a code block:

debounce = false
script.Parent.MouseEnter:connect(function(enter)
script.Parent.BorderSizePixel = 3 
script.Parent.MouseButton1Click:connect(function(onClick) 
for i, player in pairs(game.Players:GetChildren()) do 
if player.Points.Value >= 100 then 
player.Points.Value = player.Points.Value - 100 
if debounce == false then 
debounce = true 
 local ks = game:GetService("ReplicatedStorage").Swords.KnightsSword    ks:Clone().Parent = player.Backpack 
 ks:Clone().Parent = player.StarterGear 
 debounce = false 
 end 
 end 
 end 
 end) 
 end) 
Ad

Answer this question