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 get 2 functions to switch when i click the block?

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

✓ Accepted answer

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!

3 comments

0

you helped a lot...u reminded me of this :) thx

0

if opened then ... else end is MUCH cleaner

0

It does not make a difference, and I find elseif easier to read.

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