I am trying to tween these two parts, but they are rotating from the centre and not from the left/right. How do I fix this?
Video: https://streamable.com/3qg6tt
My Code:
local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Settings = require(RS.GateSettings)
local model = script.Parent
local trigger = model.TouchPart
local left = model.GateL
local right = model.GateR
local leftro = CFrame.Angles(0,math.rad(90),0)
local rightro = CFrame.Angles(0,math.rad(-90),0)
local fleftro = left.CFrame * leftro
local frightro = right.CFrame * rightro
local activated = false
local tweenInfo = TweenInfo.new(
Settings.Speed,
Enum.EasingStyle.Quart,
Enum.EasingDirection.Out,
0,
true,
0
)
local function open(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player and not activated then
activated = true
local tweenL = TweenService:Create(left, tweenInfo, {CFrame = fleftro})
local tweenR = TweenService:Create(right, tweenInfo, {CFrame = frightro})
tweenL:Play()
tweenR:Play()
tweenL.Completed:Wait()
activated = false
end
end
trigger.Touched:Connect(open)
