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

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

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)


1 comment

0

How was I downvoted? I didn't request.

1 answer

✓ Accepted answer

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.

2 comments

0

Please remember that 'arrays' are called 'tables' in Lua.

0

Woops .-.

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