local hinge = script.Parent.Frame.Hinge local door = script.Parent.Door local handle1 = script.Parent.Handle1 local handle2 = script.Parent.Handle2 local targetAngle = -90 local open = false local function DoorFunction () if open == false then hinge.TargetAngle = 0 open = true print("open") end if open == true then hinge.TargetAngle = targetAngle open = false print("close") end end handle1.ClickDetector.MouseClick:connect(DoorFunction) handle2.ClickDetector.MouseClick:connect(DoorFunction)
i want to make the door opens when the handle is clicked and closes when the handle is clicked again
PLS help!
I just connected the 2 'if's, if open is false then it read the statement(Updates 'open' to true) and reads another condition which checks if open is true... gotta stop here, bai
http://wiki.roblox.com/index.php?title=Conditional_statement#Elseif
local hinge = script.Parent.Frame.Hinge local door = script.Parent.Door local handle1 = script.Parent.Handle1 local handle2 = script.Parent.Handle2 local targetAngle = -90 local open = false local function DoorFunction () if open == false then hinge.TargetAngle = 0 open = true print("open") elseif open == true then hinge.TargetAngle = targetAngle open = false print("close") end end end handle1.ClickDetector.MouseClick:connect(DoorFunction) handle2.ClickDetector.MouseClick:connect(DoorFunction)