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

How do i get 2 functions to switch when i click the block?

Asked by 10 years ago

say i want a door to open and close when i clicked it...how would i get it to go back and forth on each click?

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Just create a variable and check if it is true or false.

local opened = false

if opened == false then
    opened = true
    --open door
elseif opened == true then
    opened = false
    --close door
end

That's the basic logic of it, hope i helped!

0
you helped a lot...u reminded me of this :) thx snoppyploptart 59 — 10y
0
`if opened then ... else end` is MUCH cleaner BlueTaslem 18071 — 10y
0
It does not make a difference, and I find elseif easier to read. Perci1 4988 — 10y
Ad

Answer this question