Unable to cast dictionary to tweeninfo again

What do you want to achieve? I’m trying to tween something but it keeps saying “unable to cast dictionary to tweeninfo”, not sure why because all the variables look correct.

What solutions have you tried so far? Looked everywhere cant find any answer because this is unique to my script

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local tweenService = game:GetService("TweenService")
local tornadopart = script.Parent

local tweeninfo = TweenInfo.new(
	60,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	true,
	0

)


local move1 = {
	Position = Vector3.new(460.012, 229.913, -376.632),
	
}

local move2 = {
	Position = Vector3.new(-52.059, 229.913, -376.632)
	
}

local tween = tweenService:Create(tornadopart, TweenInfo, {Position = move1.Position}, {Position = move2.Position})

tween:Play()

You have to create a tween for move1 and another for move2.

local tween = tweenService:Create(tornadopart, TweenInfo, move1)
tween:Play()
tween.Completed:Wait()
tween:Destroy()
tween = tweenService:Create(tornadopart, TweenInfo, move2)
tween:Play()
tween.Completed:Wait()
tween:Destroy()
1 Like

You can try a for loop instead.

Pseudocode:

local location = {
     1 = Vector3.new{1,2,3}
     2 = Vector3.new{4,5,6}
}

for i = 1,2 do
     local tween = tweenService:Create(tornadopart,TweenInfo,{Position = location.i}
     tween:play()
end)

Disclaimer: I didn’t test if this idea will work so it may or may not work. :man_shrugging:

1 Like

That doesnt fix it, same error

If it’s that you want the tornado to tween to one position, then tween to the next after it has reached its target, then you’ll have to create two separate tweens:

local tweeninfo = TweenInfo.new(
	60,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	true,
	0
)

local tween1 = tweenservice:Create(tornadopart, tweeninfo, move1)
local tween2 = tweenservice:Create(tornadopart, tweeninfo, move2)

tween1:Play()
tween1.Completed:Wait()

tween2:Play()
tween2.Completed:Wait()

Also, the reason why you were getting the error in your code is because you’re passing the actual TweenInfo class itself, not the newly instantiated object class created using TweenInfo, defined as tweeninfo in your code

Yeah I just realized that and fixed it now it works, no worries and thanks for the help