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.
01 | local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor |
02 | local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor |
03 | local Sound = script.Parent.Sound |
04 | local debounce = false |
05 | local door = false |
06 | local Rotation = LeftDoor.CFrame - LeftDoor.Position |
07 |
08 | script.Parent.ClickDetector.MouseClick:connect( function () |
09 | if not debounce then debounce = true |
10 | if not door then door = true |
11 | Sound.Playing = false |
12 | Sound.Playing = true |
13 | for i = 1 , 14 do |
14 | LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector 3. new( 0 , 1 , 0 )) |
15 | wait() |
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)
01 | local RunService = game:GetService( "RunService" ) |
02 | local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor |
03 | local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor |
04 | local Sound = script.Parent.Sound |
05 | local debounce = false |
06 | local door = false |
07 | local Rotation = LeftDoor.CFrame - LeftDoor.Position |
08 |
09 | RunService.RenderStepped:Connect( function () |
10 | LeftDoor.Orientation = Vector 3. new( 0 , 0 , 0 ) -- Put the original Orientation of the door in the brackets |
11 | RightDoor.Orientation = Vector 3. new( 0 , 0 , 0 ) -- Put the original Orientation of the door in the brackets |
12 | end ) |
13 |
14 | script.Parent.ClickDetector.MouseClick:connect( function () |
15 | if not debounce then debounce = true |
Aha, didn't really expect it to be this easy. I fixed it by changing the orientation in the script each time.
01 | local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor |
02 | local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor |
03 | local Sound = script.Parent.Sound |
04 | local debounce = false |
05 | local door = false |
06 | local Rotation = LeftDoor.CFrame - LeftDoor.Position |
07 |
08 | script.Parent.ClickDetector.MouseClick:connect( function () |
09 | if not debounce then debounce = true |
10 | if not door then door = true |
11 | Sound.Playing = false |
12 | Sound.Playing = true |
13 | for i = 1 , 14 do |
14 | LeftDoor.Orientation = Vector 3. new( 0 , - 90 , 0 ) |
15 | LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector 3. new( 0 , 1 , 0 )) |