Hello,
I am having trouble setting up my debounce so I can stop people from spamming, any help would be appreciated.
for i, SearchGarbage in pairs(game.Workspace.InteractObjects.GarbageCans:GetChildren()) do SearchGarbage.ClickDetector.MouseClick:Connect(function(Player) local Chance = math.random(1,5) local TrashSearch = true if TrashSearch then TrashSearch = false Search:Play() wait(3) if Chance == 3 then ReplicatedStorage.GUI.Notification:Clone().Parent = Player.PlayerGui ReplicatedStorage.GUI.Notification.FoundItem.Label.Text = "Found Junk" CloneObjEvent:FireServer(ReplicatedStorage.Items.Junk) else ReplicatedStorage.GUI.Notification:Clone().Parent = Player.PlayerGui ReplicatedStorage.GUI.Notification.FoundItem.Label.Text = "Found Nothing" end end TrashSearch = true end) end
Try having the original var declaration outside of the for loop. Since, whenever it detects a click, TashSearch will always be true (Since Its Always Being Declared As True).