local CD = script.Parent
local PJ = game.ServerStorage["Pirate Juice"]
local debounce = false
CD.MouseClick:Connect(function(plr)
local bp = plr.Backpack
local PJI = PJ:Clone()
PJI.Parent = game.ReplicatedStorage
if not debounce then
if PJI.Parent == game.ReplicatedStorage then
debounce = true
PJI.Parent = bp
end
elseif debounce then
if bp["Pirate Juice"] then
wait(3)
debounce = false
print("no")
PJI:Destroy()
end
end
end)
is Pirate Juice a tool? charcharcharchar
1 Like
you should put debounce = true right after you put if not debounce, also set it back to false when your finished.
you can use a debounce like this:
-- server script inside a click detector
local clickDetector = script.Parent
local item = game:GetService("ServerStorage")["Pirate Juice"]
local debounce = {}
clickDetector.MouseClick:Connect(function(player)
if debounce[player] then
return
end
debounce[player] = true
local newItem = item:Clone()
newItem.Parent = player.Backpack
task.wait(3)
debounce[player] = nil
end)
but if this is a tool that you should only be able to have 1 of you should do:
-- server script inside a click detector
local clickDetector = script.Parent
local item = game:GetService("ServerStorage")["Pirate Juice"]
clickDetector.MouseClick:Connect(function(player:Player)
if not player.Character then
return
end
if player.Character:FindFirstChild(item.Name) or player.Backpack:FindFirstChild(item.Name) then
return
end
local newItem = item:Clone()
newItem.Parent = player.Backpack
end)
Yes, it is a tool characaracara
You should try my second solution in that case
Cheers… charcharcharcharcharchar
Interesting solution, never tried tables for debounce, but at least it works.
this way allows for multiple people to do a certain action at the same time while at the same time ratelimiting them
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.