When I play my tween it moves the part to 0,10,0[Closed because I'm stupid and figured it out]

For some reason I have this parented to a part, and when I play the tween it does everything correctly except it moves the part to zero. I have tried putting positions inside the property table, but it still starts at 0,10,0 .Can anybody tell me why this is happening?

local TweenService = game:GetService("TweenService")

local part = script.Parent

part.Position = Vector3.new(0, 10, 0)

part.Anchored = true

part.Parent = game.Workspace

local function CreateAnimation(part,duration,easingstyle,easingdirection,repeatcount,reversing,delaybetweenpoints,property)

     local tweenInfo = TweenInfo.new(

          duration, -- Time

          easingstyle, -- EasingStyle

          easingdirection, -- EasingDirection

          repeatcount, -- RepeatCount (when less than zero the tween will loop indefinitely)

          reversing, -- Reverses (tween will reverse once reaching it's goal)

          delaybetweenpoints -- DelayTime

     )

     local tween = TweenService:Create(part, tweenInfo, property)

     return tween

end

local animation = CreateAnimation(script.Parent,10,Enum.EasingStyle.Back,Enum.EasingDirection.Out,10,true,0.5,{Position = Vector3.new(5,5,5)})

script.Parent.Position = script.Parent.Position

animation:Play()
1 Like

why using a function for tweening? use a regular tweenservice.

1 Like

Its because my brain can’t handle it, so I create module scripts to simplify them sometimes.

I just realized the issue. This is what happens when I copy code

part.Position = Vector3.new(0, 10, 0)

This assignment sets the part’s position to 0, 10, 0 in the world space.

Just to explain the issue for anyone that may have been confused.