Tween not working

I’m using this script to tween a model, but the model is going forward not to the side.
What it’s doing:


What I want:

My script:

for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0.125*(-i),0,0)
end
wait(1)
for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0.125*(i),0,0)
end

It seems that you are just tweening the wrong axis, try:

for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0,0.125*(-i),0)
end
wait(1)
for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0,0.125*(i),0)
end

If not try this:

for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0,0,0.125*(-i))
end
wait(1)
for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0,0,0.125*(i))
end

The second one works, but it goes the opposite direction

Just use TweenService and set the goal to be Position = Vector3.new(x,y,z)

Then try this:

for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0,0,-0.125*(-i))
end
wait(1)
for i = 0,6,0.2 do
	wait()
	script.Parent.Door.PrimaryPart.CFrame = script.Parent.Door.PrimaryPart.CFrame * CFrame.new(0,0,-0.125*(i))
end

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