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

How to call 2 different functions under 1 event ?

I have been scripting for 2 weeks now, my question is how can i possibly call 2 functions under 1 event, for example if I am trying to create a animated button door how am i gonna make the functions not run at the same time ?

Thanks

2 answers

✓ Accepted answer

You just need to use if and elseif statements:

local Opened = false
script.Parent.MouseClick:Connect(function() --Script is located in a "ClickDetector"
	if Opened == false then --Checks to see if it's false
		Opened = true --sets to true
		print("Door is open")
	elseif Opened == true then --If the value is not false it immediately runs this part
		Opened = false
		print("Door is closed")
	end
end)

More info about if statements/Conditional statements: https://developer.roblox.com/en-us/articles/Conditional-Statements-in-Lua

1 comment

0

thank you so much, now my night vision button script is completed, your answer will be have a huge impact over my future goals

function a()
	print("bruh")
end

function b()
	print("moment")
end

event:Connect(function()
	a()
	b()
end)

>>>bruh
>>>moment

do you mean something like this?

1 comment

0

no i mean how do i make the door open when i press the button and how do i make it close when i press the button again

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