Wrong tween axis for door

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	

You’re using CFrames, you need to multiply, not adding up
door.CFrame * Vector3.new(-4.72,0,0)

Like said above where you are setting the CFrame, you need to multiply with a CFrame rather then a Vector3, something like this:

door.CFrame * CFrame.new( -4.72, 0, 0 )

now it’s just not working what do I do ?

What’s the error?
try door.CFrame * CFrame.new( -4.72, 0, 0 )

I just got the wrong axis lemme fix it

I did it it’s working, why do I have to multiply it ?

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
2 Likes

Oh thanks for the explanation I really didn’t understood why it worked that way thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.