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

New clickdetector wont replace the old one?

Asked by 5 years ago
Edited 5 years ago

I edited a script and I made it where the item giver has a cooldown heres the script:

local PassId = 4835177
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local BloxyCola = ReplicatedStorage:WaitForChild("????? ???? ???")
local player = game.Players.LocalPlayer
local bloxy = workspace:WaitForChild("itemgiver1")

bloxy.ClickDetector.MouseClick:Connect(function(player)
    BloxyCola:Clone().Parent = player.Backpack
    script.Parent.Transparency=1
    script.Parent.ClickDetector:Destroy()
        for i = 10, 1, -1 do -- give it a 60 second cooldown and show the timer
            script.Parent.BillboardGui.TextBox.Text = tostring(i)
            wait(1)


                end
        script.Parent.BillboardGui.TextBox.Text=(" ") --replaces text and resets everything back to normal
    script.Parent.Transparency=0
     local ClickDetector = Instance.new("ClickDetector")
    ClickDetector.Parent = bloxy
    ClickDetector.MaxActivationDistance = 10




end)

but when the item spawns back i can't click it again, even though it shows the click cursor. what am i doing wrong here?

0
. User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

There is no reason to remove the clickdetector, you could instead use debounce. Debounce allows you to essentially deny all incoming requests from a connection until it is returned to false

local PassId = 4835177
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local BloxyCola = ReplicatedStorage:WaitForChild("????? ???? ???")
local player = game.Players.LocalPlayer
local bloxy = workspace:WaitForChild("itemgiver1")
local debounce = false

bloxy.ClickDetector.MouseClick:Connect(function(player)
    if not debounce then
        debounce = true -- stops any more clicks going through because of the line above this one
        BloxyCola:Clone().Parent = player.Backpack
        script.Parent.Transparency=1
        for i = 10, 1, -1 do -- give it a 60 second cooldown and show the timer
            script.Parent.BillboardGui.TextBox.Text = tostring(i)
            wait(1)
        end
        script.Parent.BillboardGui.TextBox.Text=(" ") --replaces text and resets everything back to normal
        script.Parent.Transparency = 0
        debounce = false -- allow the script to be run again
    end
end)
0
thank you for teaching me about debounce but it wont turn off still. now the cursor wont show up retracee 68 — 5y
0
oh yeah i fixed it so it doesn't remove the line that you destroy it on User#9949 0 — 5y
Ad

Answer this question