The part is not preventing players from clicking multiple times

  1. What do you want to achieve? Keep it simple and clear!

I am a beginner scripter, I’m starting with small task and I was just messing the code around. Okay so, I want the part to fades in/out and prevent player from clicking multiple times and when you press the “Delete” key it will delete the part then it will wait for 5 seconds before cloning another part from ReplicatedStorage.

  1. What is the issue? Include screenshots / videos if possible!
  • the part is not preventing players from clicking multiple times even though I am using debounce.
  • part is not destroying from the server after I press the “Delete” key
  • it is not cloning the part from ReplicatedStorage
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried looking for solutions on devforum, youtube and I also do some research on google. But I can’t find a way through to fix my script.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local ClickDoor = game.Workspace.ClickDoor
local ClickDetector = game.Workspace.ClickDoor.ClickDetector
local UserInputService = game:GetService("UserInputService")
local RS = game.ReplicatedStorage.ClickDoor
local debounce = false

ClickDetector.MouseClick:Connect(function()
	if debounce == false  then
		debounce = true
	ClickDoor.Transparency = 0.3
	wait(0.3)
	ClickDoor.Transparency = 0.5
	wait(0.5)
	ClickDoor.Transparency = 0.6
	wait(0.7)
	ClickDoor.Transparency = 0.8
	wait(0.1)
	ClickDoor.Transparency = 1
	ClickDoor.CanCollide = false
	local Explosion = Instance.new("Explosion",workspace.ClickDoor)
	Explosion.BlastPressure = 10000
	Explosion.BlastRadius = 10000
	Explosion.Position = Vector3.new(16.5, 15.5, 14)
	UserInputService.InputBegan:Connect(function(Input)
		if Input.KeyCode == Enum.KeyCode.Delete then
			ClickDoor:Destroy()
			print("ClickDoor has being Destroyed!")
			wait(5)
			RS = game.Workspace
			RS.Position = Vector3.new()
			local Clone = RS:Clone(16.5, 15.5, 14)
			print("ClickDoor has been Cloned")
			debounce = false
			end
		end)
	end
end)

ClickDetector.RightMouseClick:Connect(function()
	if debounce == false then
		debounce = true
	ClickDoor.Transparency = 0.8
	wait(0.4)
	ClickDoor.Transparency = 0.5
	wait(0.6)
	ClickDoor.Transparency = 0.3
	wait(0.7)
	ClickDoor.Transparency = 0.1
	wait(0.1)
	ClickDoor.Transparency = 0
	ClickDoor.CanCollide = true
	debounce = false
	end
end)

I’d really hope someone could help me with this.
Thanks!

does both functions should share the same debounce?

Yes, they both shared the same debounce.

it seems you put all the work in same line with the “if debouce == false” try copy the entire script, clear the script and paste the script that you copied, putting script work in same space line with the “if” may result “if” bypass.

do you mean put all the end at the very last line?

no, I mean after you put the “if” after the debouce = true the work for the script is in same space line as the “if”, in my experience of scripting, at some point it can result bypass even if it doesn’t reach end yet.