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

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

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)
Ad

Answer this question