Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I tried to preform a "if" function to prent the user from clicking several times?

local Button = Game.Workspace.Gate.Part

local function BigGate() if Game.Workspace.Gate.Door.Part1.Position == (-284.5,45.907,123.75) for i=1, 200 do Game.Workspace.Gate.Door.Part1.CFrame = Game.Workspace.Gate.Door.Part1.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part2.CFrame = Game.Workspace.Gate.Door.Part2.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part3.CFrame = Game.Workspace.Gate.Door.Part3.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part4.CFrame = Game.Workspace.Gate.Door.Part4.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part5.CFrame = Game.Workspace.Gate.Door.Part5.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part6.CFrame = Game.Workspace.Gate.Door.Part6.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part7.CFrame = Game.Workspace.Gate.Door.Part7.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part8.CFrame = Game.Workspace.Gate.Door.Part8.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part9.CFrame = Game.Workspace.Gate.Door.Part9.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part10.CFrame = Game.Workspace.Gate.Door.Part10.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part11.CFrame = Game.Workspace.Gate.Door.Part11.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part12.CFrame = Game.Workspace.Gate.Door.Part12.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part13.CFrame = Game.Workspace.Gate.Door.Part13.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part14.CFrame = Game.Workspace.Gate.Door.Part14.CFrame + Vector3.new(0,0.1,0) Game.Workspace.Gate.Door.Part15.CFrame = Game.Workspace.Gate.Door.Part15.CFrame + Vector3.new(0,0.1,0) wait (0.05) end

end

end

Button.ClickDetector.MouseClick:connect(BigGate)

1 answer

Please, next time put all of your code in Code Block.

And putting if statements everywhere is completely unnecessary. Use Debounce to prevent multiple clickings.

local Button = workspace.Gate.Part
local db = false

Button.ClickDetector.MouseClick:connect(function()
	if db == false then
		db = true
		--Your Code--
		wait(1)
		db = false
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.