Tween causing part to go in the completely wrong position even though numbers are correct

I am trying to tween a barrier that goes up and down, but I want to make it so I can have the entire model anywhere and it will always work. To do that, I need to make a tween that subtracts and adds values to the position.

The thing is, all of my numbers are correct, but when the tween occurs, the part goes to the complete wrong position. I have tried everything to try and fix this.

Video

Script


local barrier = script.Parent.Barrier

local info = TweenInfo.new(1)

local up = {

Position = barrier.Position + Vector3.new(0, 4.153, -4.153),

Orientation = Vector3.new(-90, 0, 0)

}

local down = {

Position = barrier.Position - Vector3.new(0, 4.153, -4.153),

Orientation = Vector3.new(0, 0, 0)

}

local upTween = tweenService:Create(barrier, info, up)

local downTween = tweenService:Create(barrier, info, down)

upTween:Play()

wait(5)

downTween:Play()

I am not sure why you are tweening the position, shouldn’t you just tween the orientation?

this is what happens when i try to tween just the orientation

image

That meaning you are not tweening the orientation correctly, try messing around with the numbers/the face of the part. Sorry for not helping that much because I am on my phone. However, tweening the position is pointless.

but when i move the part to where its supposed to be in studio, the position and the orientation changes. i copied the values for when it is up and when it is down, then put that in the script.

Try setting the down position to this when it runs

local down = {

	Position = barrier.Position - Vector3.new(0, 0, 0),

	Orientation = Vector3.new(0, 0, 0)

}
barrier.Position - Vector3.new(0, 0, 0) --is equal to 'barrier.Position'

im confused on why it worked, but it did.