Unable to cast to Dictionary

I am currently trying to tween a bullet to move to the enemy’s primary part position. I keep on getting Unable to cast to Dictionary.

local module = {}

local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	1, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.InOut, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

function module.Attack(Unit, Target)
	local Folder = script.Parent.Parent
	local Bullet = Folder.Bullet:Clone()
	Bullet.Parent = workspace
	Bullet.Position = Unit.Gun.Position

	local Tween = TweenService:Create(Bullet, tweenInfo, Target.PrimaryPart.Position)
	Tween:Play()
	
	Tween.Completed:Connect(function()
		Bullet:Destroy()
	end)
end

return module
1 Like

Which line did you find the error in?

I believe this line is causing the problems, but I am unsure because it is inside a module script.

	local Tween = TweenService:Create(Bullet, tweenInfo, Target.PrimaryPart.Position)

You need to make it a table like:
local Tween = TweenService:Create(Bullet, tweenInfo, {Bullet.Position = Target.PrimaryPart.Position})
also if your bullet is a model use the primarypart/welded part

1 Like

Thank you, also my bullet is a part so it should work fine now.

Nope, it isn’t working.
Screen Shot 2022-03-11 at 7.48.26 PM

I tried but it still didn’t work.

{Bullet.Position == Target.PrimaryPart.Position})

also i see you do bullet.Position, with tweening you only have to give it the attribute you want to change. the object is only required in the first parameter.

Change it to:

{Position = Target.PrimaryPart.Position}

TweenService takes the property name and value

1 Like