Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tween Error Unable to cast to dictionary?

Asked by 2 years ago

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()

0
Put the code between the code block next time, yes? RAFA1608 543 — 2y

1 answer

Log in to vote
0
Answered by
RAFA1608 543 Moderation Voter
2 years ago
Edited 2 years ago

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!

0
Thanks very much I just inputted your suggestions and that fixed the problem. abelgetachew19 -10 — 2y
Ad

Answer this question