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

Anyone know how to disable a ClickDetector?

Asked by 9 years ago

I am making a farming button. But I want to prevent spams while the wheat is regrowing. Is there anyway I can disable the ClickDetector when the wheat has grown again? This is my code:

01function onClicked(player)
02game.Players:FindFirstChild(player.Name).leaderstats.Coins.Value = game.Players:FindFirstChild(player.Name).leaderstats.Coins.Value + 100
03game.Players.thenasafarouk.leaderstats.Coins.Value = game.Players.thenasafarouk.leaderstats.Coins.Value + 20
04--I want to disable it here
05game.Workspace.WheatSix.Transparency = 1
06game.Workspace.WheatFive.Transparency = 1
07game.Workspace.WheatFour.Transparency = 1
08game.Workspace.WheatThree.Transparency = 1
09game.Workspace.WheatTwo.Transparency = 1
10game.Workspace.WheatOne.Transparency = 1
11wait(60)
12game.Workspace.WheatSix.Transparency = 0
13game.Workspace.WheatFive.Transparency = 0
14game.Workspace.WheatFour.Transparency = 0
15game.Workspace.WheatThree.Transparency = 0
16game.Workspace.WheatTwo.Transparency = 0
17game.Workspace.WheatOne.Transparency = 0
18end
19--Then I want to enable it here
20script.Parent.ClickDetector.MouseClick:connect(onClicked)

Thanks, thenasafarouk

1 answer

Log in to vote
1
Answered by
Acheo 230 Moderation Voter
9 years ago

This would call for a debounce. Here's your remodified script:

01local debounce = true
02 
03function onClicked(player)
04if debounce == true then
05game.Players:FindFirstChild(player.Name).leaderstats.Coins.Value = game.Players:FindFirstChild(player.Name).leaderstats.Coins.Value + 100
06game.Players.thenasafarouk.leaderstats.Coins.Value = game.Players.thenasafarouk.leaderstats.Coins.Value + 20
07debounce = false
08game.Workspace.WheatSix.Transparency = 1
09game.Workspace.WheatFive.Transparency = 1
10game.Workspace.WheatFour.Transparency = 1
11game.Workspace.WheatThree.Transparency = 1
12game.Workspace.WheatTwo.Transparency = 1
13game.Workspace.WheatOne.Transparency = 1
14wait(60)
15game.Workspace.WheatSix.Transparency = 0
View all 24 lines...
0
Yea I got it. But what I did is that I changed the MaxActivationDistance thenasafarouk 25 — 9y
0
Ah, okay.. if you need any help with any scripts you can message me on ROBLOX. I'm very experienced. Acheo 230 — 9y
0
Does it really need to be called debounce ? Or can it be called anything you want rupertrosse 39 — 5y
Ad

Answer this question