Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Tween Error Unable to cast to dictionary?

The error is unable to cast dictionary and its talking about the "local movingObstacle" line.


local part = game.Workspace.Union local TweenService = game:GetService("TweenService")

local Info = TweenInfo.new( 1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, -1, false, .1 )

local goals = {

part.Position ==  Vector3.new(8.3, -0.1, 70.3)

}

local movingObstacle = TweenService:Create(part, TweenInfo, goals)

movingObstacle:Play()

1 comment

0

Put the code between the code block next time, yes?

1 answer

✓ Accepted answer

Howdy!

You see, your table isn't a dictionary, because part.Position == Vector3.new(8.3, -0.1, 70.3) is a comparison between a Vector3 and a Vector3, therefore, it can only be true or false.

local goals = {
	part.Position == Vector3.new(8.3, -0.1, 70.3) --if part has this position then it becomes true, otherwise false
}

To fix this, replace the comparing statement == with the defining statement =

local goals = {
	part.Position = Vector3.new(8.3, -0.1, 70.3)
}

However, if you run this code, it won't work either, because you are defining the part's Position as a entry, and the tween can't recognize it. To fix it, you need to define it as just Position.

local goals = {
	Position = Vector3.new(8.3, -0.1, 70.3)
}

I hope this explained what went wrong with your code.

If you have any questions, feel free to ask them below!

1 comment

0

Thanks very much I just inputted your suggestions and that fixed the problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.