Hello,
As from my last post, I have been able to make a script that allows the door that I'm working on to move up and down from the click of a button. The only issue I have now is that upon pressing the button, the door will rotate 90 degrees, making it look weird and out of place.
I've also had a lot of issues with this in the past, yet just scrap the idea as I can never figure out a way to fix this.
local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor local Sound = script.Parent.Sound local debounce = false local door = false local Rotation = LeftDoor.CFrame - LeftDoor.Position script.Parent.ClickDetector.MouseClick:connect(function() if not debounce then debounce = true if not door then door = true Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3.new(0,1,0)) wait() end debounce = false else if door then door = false Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3.new(0,1,0)) wait() end debounce = false end end end end)
The door works perfectly fine, its just the rotation. I have seen many forms about this, yet the explaining on them is very little and I have no idea where to place them into my script.
If anyone could help, it would be greatly appreciated.
Try this (may not be the best solution)
local RunService = game:GetService("RunService") local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor local Sound = script.Parent.Sound local debounce = false local door = false local Rotation = LeftDoor.CFrame - LeftDoor.Position RunService.RenderStepped:Connect(function() LeftDoor.Orientation = Vector3.new(0,0,0)-- Put the original Orientation of the door in the brackets RightDoor.Orientation = Vector3.new(0,0,0)-- Put the original Orientation of the door in the brackets end) script.Parent.ClickDetector.MouseClick:connect(function() if not debounce then debounce = true if not door then door = true Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3.new(0,1,0)) wait() end debounce = false else if door then door = false Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3.new(0,1,0)) wait() end debounce = false end end end end)
Aha, didn't really expect it to be this easy. I fixed it by changing the orientation in the script each time.
local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor local Sound = script.Parent.Sound local debounce = false local door = false local Rotation = LeftDoor.CFrame - LeftDoor.Position script.Parent.ClickDetector.MouseClick:connect(function() if not debounce then debounce = true if not door then door = true Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.Orientation = Vector3.new(0, -90, 0) LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3.new(0,1,0)) LeftDoor.Orientation = Vector3.new(0, -90, 0) wait() end debounce = false else if door then door = false Sound.Playing = false Sound.Playing = true for i = 1,14 do LeftDoor.Orientation = Vector3.new(0, -90, 0) LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3.new(0,1,0)) LeftDoor.Orientation = Vector3.new(0, -90, 0) wait() end debounce = false end end end end)