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

How do I make more than 1 gate open from one trigger?

Asked by
Qxest 25
10 years ago

Okay, so far I have this script. The model link is: http://www.roblox.com/First-GUI-Controlled-gate-item?id=153689396

--Made by iEternalFire. (Creator of the first GUI gate)
local trigger = script.Parent
local gate = game.Workspace.Gate

moving = false
open = false

function onClick()

    if open == false and moving == false then

        moving = true
        script.Parent.Text = "Open Gate"
        for i = 1, (gate.Size.Y * 10 + 1) do
            wait()
            gate.CFrame = gate.CFrame*CFrame.new(0, -0.1, 0)
        end

        moving = false
        open = true

    elseif open == true and moving == false then

        moving = true
        script.Parent.Text = "Close Gate"
        for i = 1, (gate.Size.Y * 10 + 1) do
            wait()
            gate.CFrame = gate.CFrame*CFrame.new(0, 0.1, 0)
        end

        moving = false
        open = false

    end

end

script.Parent.MouseButton1Down:connect(onClick)


0
How was I downvoted? I didn't request. Qxest 25 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

How I would do it:

Gates itself have bool properties Open and Moving. There would be a separate script to change their values.

Move the stuff you have in OnClick into another method called OpenGate or something.

That method would require an identifying parameter so it can know which gate to open.

Keep an array at the top of your script filled with the identifiers of the gates you want to open.

Finally, in the OnClick, iterate through the array, passing it to OpenGate on every iteration.

0
Please remember that 'arrays' are called 'tables' in Lua. TheGuyWithAShortName 673 — 10y
0
Woops .-. Zzzip42Strike 30 — 10y
Ad

Answer this question