TweenService asking for CFrame not table

I have a gun script and when I call the RemoteEvent it shoots a bullet to a point. The script is erroring out when I call TweenService.

local bullet = ReplicatedStorage.Bullet:Clone()
bullet.CFrame = gun.Handle.CFrame
bullet.Parent = workspace

local bulletDeration = derection.Magnitude / 15

TweenService:Create(bullet, TweenInfo.new(bulletDeration), {CFrame * CFrame.new(mousePosition)}):Play()
-- I am getting the error "invalid argument #1 (CFrame expected, got table)" on the line above

I have tried to change “bullet” to “bullet.CFrame”, also I added a “CFrame =” in the beginning of the curly braces(thx @S3CR3TH4CK).

2 Likes

You need to specify what property needs to be changed, in this case it’s CFrame therefore you have to use a dictionary:

{
    CFrame = CFrame * CFrame.new(mousePosition)
}

I already tried that can you expand.

Actually you don’t need the bullet.CFrame in this case, you can simply do:

TweenService:Create(bullet, TweenInfo.new(bulletDeration), {CFrame = CFrame.new(mousePosition)}):Play()

@TimeKillsTheWeak

1 Like

Thx but now it is turned a 90 degree angle.

That’s because it’s adding the bullet’s CFrame which includes the bullet’s rotation to the mousePosition CFrame

This should work to solve the problem:
TweenService:Create(bullet, TweenInfo.new(bulletDeration), {CFrame = CFrame.new(mousePosition)}):Play()

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