How to tween position using vector3?

I am trying to create a scripted animation of a person shooting a bullet. I want the bullet to move 50 studs away from the origin on the z axis. I am currently trying to use tweenService and Vector3, but when I run the code it says this:

TweenService:Create property named ‘Position’ cannot be tweened due to type mismatch (property is a ‘UDim2’, but given type is ‘Vector3’)

The code I am using is this:

local clone = game.Workspace.WorkMap.Bullets.Bullet:Clone()
clone.Transparency = 0
clone.Position = v.Gun.Position -- I am using this in a loop, so v is the thing that is shooting the bullet
clone.Parent = game.Workspace.WorkMap.Bullets
local bulletMove = TweenService:Create(game.Players.LocalPlayer.PlayerGui.FadeGui.Frame,TweenInfo.new(0.5,Enum.EasingStyle.Linear),{Position = Vector3.new(clone.Position.X, clone.Position.Y, clone.Position.Z - 50)}):Play()

Is there a way to tween only one axis of an object’s position?

You are trying to tween a 2D object, using a vector3 position, which is not possible.

local clone = game.Workspace.WorkMap.Bullets.Bullet:Clone()
clone.Transparency = 0
clone.Position = v.Gun.Position -- I am using this in a loop, so v is the thing that is shooting the bullet
clone.Parent = game.Workspace.WorkMap.Bullets
local bulletMove = TweenService:Create(BULLET,TweenInfo.new(0.5,Enum.EasingStyle.Linear),{Position = Vector3.new(clone.Position.X, clone.Position.Y, clone.Position.Z - 50)}):Play() -- "BULLET": put the bullet part instead of a 2D object here

Replace “BULLET” with your bullet part.

1 Like

I feel dumb, I copied the code from another one of my scripts and forgot to change that.

1 Like