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

why do I get an Unable to cast to Dictionary error?

Asked by 4 years ago
Edited 4 years ago

I keep getting an error "Unable to cast to Dictionary" even though there isn't a dictionary/table. My tween only contains 1 number that aren't in a dictionary.

1local Number1 = 0
2 
3Number1 += 1
4local Tween = game:GetService("TweenService")
5local Inf =TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,1,false,0.1)
6Tween:Create(Number1 , Inf, Number1 - 1):Play()

Why do I get this error?

1 answer

Log in to vote
1
Answered by 4 years ago

It says it cannot cast to dictionary because the Create method expects a dictionary as the third parameter. You cannot tween number values, you must tween an instance. The third parameter would hold the new properties of the instance in a dictionary, even if it is one value. If you want to tween a number, use a floatValue and adjust the value

https://developer.roblox.com/en-us/api-reference/function/TweenService/Create

01-- Script example for tweening a float value
02local Tween = game:GetService("Tween");
03 
04local num = Instance.new("FloatValue");
05num.Value = 1;
06num.Parent = game.Workspace;
07 
08local info =TweenInfo.new(
09    0.5,
10    Enum.EasingStyle.Linear,
11    Enum.EasingDirection.InOut,
12    1,
13    false,
14    0.1
15);
View all 21 lines...
Ad

Answer this question