Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to prevent the sliding door from rotation?

Asked by
Yuuwa0519 197
5 years ago
Edited 5 years ago

I have made a sliding door for my game, but when it opens it somehow changes the orientation of door from 0,90,0 to 0,0,0 instead of just sliding. I am still a starter so i have no idea what to do. code:

local TweenService = game:GetService("TweenService")
local door1 = script.Parent:WaitForChild("Door1")
local door2 = script.Parent:WaitforChild("Door2")
local tweeningInformation = TweenInfo.new(1.2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local door1Open = {Cframe = Cframe.new(Postion)}
local door2Open = {Cframe = Cframe.new(Position)}
local door1Close = {Cframe = Cframe.new(Position)}
local door2Close = {Cframe = Cframe.new(position)}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
local tween2open = TweenService:Create(door2,tweeningInformation,door2Open)
local tween2close = Tweenservice:Create(door2,tweeningInformation,door2Close)
script.Parent.Detector1.Touched:Connect(function(hit)
tween1open:Play()
tween2open:Play()
wait(3)
tween1close:Play()
tween2close:Play()
end)
script.Parent.Detector2.Touched:Connect(function(hit)
tween1open:Play()
tween2open:Play()
wait(3)
tween1close:Play()
tween2close:Play()
end)

2 answers

Log in to vote
0
Answered by 5 years ago

A "cframe.new(Vector3...)" just have location set. And Part.CFrame = CFrame.new() just overwrite the cframe You just need to multiplicate the CFrame with CFrame.fromEulerAnglesXYZ(math.rad(part.Rotation.X), math.rad(part.Rotation.Y), math.rad(part.Rotation.Z))

0
Thanks for explanation. However, i think i still dont understand it so if it`s not inconvinient, will you show me the where i should put that bit of code? Thank you :D Yuuwa0519 197 — 5y
Ad
Log in to vote
0
Answered by
xg1y 41
5 years ago
Edited 5 years ago

Due to the base plate and orientations of parts, it could be that your part is defaulted to an orientation (Eg; 0,90,0) and due to you changing the cframe, it resets the orientation to (0,0,0)

What you'd want to do is to set the orientation and the cframe, to the part's orientation and the changing cframe.

Answer this question