Weird problem with tweening?

Hi everyone, I took some time today to learn how to use the tween service for a TF2-style resupply locker I made. It fully heals you and restores your weapon’s ammo.
My script does work fine, but there’s this weird issue where Door 1 isn’t tweening as it should.
Demonstration, it just kind of spins while the second door acts normally:

Here’s my full script, I’m not sure if this is a problem with my script or how I made the tween work:

local healthPack = script.Parent
local healAmount = 500
local cooldown = 3
local canHeal = true
local TweenService = game:GetService("TweenService")

local Door1 = script.Parent.Parent.d1
local Door2 = script.Parent.Parent.d2

local Endpoint1 = script.Parent.Parent.d1end.Position
local Endpoint2 = script.Parent.Parent.d2end.Position

local EndpointRot1 = script.Parent.Parent.d1end.Orientation
local EndpointRot2 = script.Parent.Parent.d2end.Orientation

local ReturnPoint1 = script.Parent.Parent.d1return.Position
local ReturnPoint2 = script.Parent.Parent.d2return.Position

local ReturnPointRot1 = script.Parent.Parent.d1return.Orientation
local ReturnPointRot2 = script.Parent.Parent.d2return.Orientation

local HalfwayPoint1 = script.Parent.Parent.d1halfway.Position
local HalfwayPoint2 = script.Parent.Parent.d2halfway.Position

local HalfwayPointRot1 = script.Parent.Parent.d1halfway.Orientation
local HalfwayPointRot2 = script.Parent.Parent.d2halfway.Orientation

local ProgressPoint1 = script.Parent.Parent.d1progress.Position
local ProgressPoint2 = script.Parent.Parent.d2progress.Position

local ProgressPointRot1 = script.Parent.Parent.d1progress.Position
local ProgressPointRot2 = script.Parent.Parent.d2progress.Orientation

local Opentime = 1
local Openspeed = 0.5
local tweeninfo = TweenInfo.new(Openspeed, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local tweeninfo2 = TweenInfo.new(Openspeed, Enum.EasingStyle.Cubic, Enum.EasingDirection.In, 0, false, 0)
local tweeninfo3 = TweenInfo.new(Openspeed, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0)
local canopen = true

local function onPartTouch(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid and canHeal == true and humanoid.Health < humanoid.MaxHealth then
		canHeal = false
		local currentHealth = humanoid.Health
		local newHealth = currentHealth+ healAmount
		humanoid.Health = newHealth
		wait(cooldown)
		canHeal = true
	end
end
healthPack.Touched:Connect(onPartTouch)

local function ontouch()
	if canopen then
		canopen = false
		progtween1 = TweenService:Create(Door1, tweeninfo, {Position = ProgressPoint1, Orientation = ProgressPointRot1})
		progtween1:Play()
		progtween2 = TweenService:Create(Door2, tweeninfo, {Position = ProgressPoint2, Orientation = ProgressPointRot2})
		progtween2:Play()
		wait(0.2)
		pretween1 = TweenService:Create(Door1, tweeninfo3, {Position = HalfwayPoint1, Orientation = HalfwayPointRot1})
		pretween1:Play()
		pretween2 = TweenService:Create(Door2, tweeninfo3, {Position = HalfwayPoint2, Orientation = HalfwayPointRot2})
		pretween2:Play()
		wait(0.1)
		tween1 = TweenService:Create(Door1, tweeninfo, {Position = Endpoint1, Orientation = EndpointRot1})
		tween1:play()
		tween2 = TweenService:Create(Door2, tweeninfo, {Position = Endpoint2, Orientation = EndpointRot2})
		tween2:play()		
		wait(0.4)
		wait(Opentime)
		pretween3 = TweenService:Create(Door1, tweeninfo2, {Position = Endpoint1, Orientation = EndpointRot1})
		pretween3:Play()
		pretween4 = TweenService:Create(Door2, tweeninfo2, {Position = Endpoint2, Orientation = EndpointRot2})
		pretween4:Play()
		wait(0.1)
		pretween3 = TweenService:Create(Door1, tweeninfo3, {Position = HalfwayPoint1, Orientation = HalfwayPointRot1})
		pretween3:Play()
		pretween4 = TweenService:Create(Door2, tweeninfo3, {Position = HalfwayPoint2, Orientation = HalfwayPointRot2})
		pretween4:Play()
		wait(0.1)
		progtween3 = TweenService:Create(Door1, tweeninfo, {Position = ProgressPoint1, Orientation = ProgressPointRot1})
		progtween3:Play()
		progtween4 = TweenService:Create(Door2, tweeninfo, {Position = ProgressPoint2, Orientation = ProgressPointRot2})
		progtween4:Play()
		wait(0.1)
		endtween1 = TweenService:Create(Door1, tweeninfo, {Position = ReturnPoint1, Orientation = ReturnPointRot1})
		endtween1:Play()
		endtween2 = TweenService:Create(Door2, tweeninfo, {Position = ReturnPoint2, Orientation = ReturnPointRot2})
		endtween2:Play()
		wait(1)
		canopen = true
		else
	end
end

script.Parent.Touched:Connect(ontouch)

I’ve checked the console every time I tried a solution, but no errors showed up. I don’t think my progress points could be the issue either, I checked them and they’re parallel to each other and have rotation corresponding to each door.

I’ve already changed the rotation on the first door but that did nothing either, which is confusing me even more.

Thanks for reading, if you know what’s going on then feel free to answer. If you need more information then you can ask me.

1 Like

What seems to be happening is the door is being rotated/flipped in the tween. Try flipping the rotation value of the left door.

I flipped it in a lot of different ways but none of them worked for some reason? I don’t understand why when rotation could probably be the only thing causing this, unless I messed something up while rotating the doors. I’ll keep trying though.

Found out the issue myself, lines 22 and 32 had faulty progress point variables, where position and orientation were swapped.

1 Like