if script.Parent.Position == Vector3.new(-74.5, 7.5, 19.5) then script.Parent.ClickDetector.MouseClick:connect(function() game.Workspace.Door.Position = Vector3.new(-80,5.5,25) game.Workspace.Door.Rotation = Vector3.new(-180,0,-180) script.Parent.Position = Vector3.new(-81.5, 7.5, 23.5) script.Parent.Rotation = Vector3.new(0, 90, 0) elseif script.Parent.Position == Vector3.new(-74.5, 7.5, 19.5) then script.Parent.ClickDetector.MouseClick:connect(function() game.Workspace.Door.Rotation = Vector3.new(0,90,0) game.Workspace.Door.Position = Vector3.new(-76, 5.5, 21) script.Parent.Position = Vector3.new(-74.5, 8.5, 19.5) script.Parent.Rotation = Vector3.new(0, 90, 0) end) end **If you can tell it is for a door that opens and closes please help**
Your problem is that you're trying to make a conditional
to activate your event
. This won't work, the event will activate reguardless of whether or not the condition returns true or false.
Also, both your conditions are the same.. so the door will always just open
Try putting the conditionals inside the event. And makeing a bool switch to check if the door is open or closed.
local open = false script.Parent.ClickDetector.MouseClick:connect(function() if open then open = false workspace.Door.Position = Vector3.new(-80,5.5,25) workspace.Door.Rotation = Vector3.new(-180,0,-180) script.Parent.Position = Vector3.new(-81.5, 7.5, 23.5) script.Parent.Rotation = Vector3.new(0, 90, 0) else open = true workspace.Door.Rotation = Vector3.new(0,90,0) workspace.Door.Position = Vector3.new(-76, 5.5, 21) script.Parent.Position = Vector3.new(-74.5, 8.5, 19.5) script.Parent.Rotation = Vector3.new(0, 90, 0) end end)
Locked by woodengop, Goulstem, and Unclear
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?