I’ve got a big problem when I open the door , the tween to slide the doors are broken is certain axis but not in others. How do I fix it ?
script:
local cs = game:GetService("CollectionService")
local doors = cs:GetTagged("DTAG")
local ts = game:GetService("TweenService")
for _,door in pairs(doors) do
local PPArt = door.PromptPart
local pp = PPArt:WaitForChild("ProximityPrompt")
local info = TweenInfo.new(3, Enum.EasingStyle.Exponential,Enum.EasingDirection.Out,0,false,0)
local sound = door.BuzzSound
local open = ts:Create(door, info, {CFrame = door.CFrame + Vector3.new(-4.72,0,0)})
local close = ts:Create(door, info, {CFrame = door.CFrame})
pp.Triggered:Connect(function()
if pp.ActionText == "Open" then
sound:Play()
open:Play() open.Completed:Wait()
pp.ActionText = "Close"
elseif pp.ActionText == "Close" then
sound:Play()
close:Play() close.Completed:Wait()
pp.ActionText = "Open"
end
end)
end
The way CFrames work in Roblox is that they have a Vector (position) and orientation. If you add or subtract a Vector3 from a CFrame, it does it in ‘global’ space, so it does not take into consideration that your door may be rotated on a different axis. Multiplying a CFrame by a second CFrame is essentially modifying or ‘moving’ the first CFrame in its own relative space.
Think of it like this, as a random example:
Door starting CFrame: I am rotated 45 degrees.
Door CFrame * CFrame( -4.72, 0, 0): I am rotated 45 degrees, now move me 4.72 units to my left according to my local orientation