local Spinner = script.Parent
local TS = game:GetService(“TweenService”)
local RandomPos = math.random(1,360)
local goal = {}
goal.Orientation = Vector3.new(0,RandomPos,0)
local tweenInfo = TweenInfo.new(5)
local tween = TS:Create(Spinner,TweenInfo,goal)
tween:Play()
Can anyone tell me why im getting the error "Unable to cast Dictionary to TweenInfo "
hans5915
(hans5915)
September 9, 2023, 7:50am
#2
You made a typo.
Make the “t” lowercase in your TS:Create() function.
So this: local tween = TS:Create(Spinner,tweenInfo,goal)
hans5915
(hans5915)
September 9, 2023, 7:51am
#4
That’s isn’t the issue. The goal is properly defined. The error is with the TweenInfo.
What the person did was use “TweenInfo”, which is a namespace reserved for luau. Meanwhile his actual variable “tweenInfo” (lowercase T) is the actual tween information.
hans5915
(hans5915)
September 9, 2023, 7:56am
#6
Again. You would have the same issue, since TweenInfo is not defined properly. Look at the actual Tween.
It’s not a logic mistake. It’s a simple typo. Read the message I sent above.
local Spinner = script.Parent
local TS = game:GetService(“TweenService”)
local RandomPos = math.random(1, 360)
local goal = {}
goal.Orientation = Vector3.new(0, RandomPos, 0)
local tweenInfo = TweenInfo.new(5)
local tween = TS:Create(Spinner, tweenInfo, goal)
tween:Play()
the issue was that you defined tweenInfo
as a variable but used TweenInfo
in TS:Create()
extra details
local goal = {}
goal.Orientation = Vector3.new(0, RandomPos, 0)
it would be cleaner and more optimised to define the table than setting it outside the variable
local goal = {Orientation = Vector3.new(0, RandomPos, 0)}
also, if you’re not going to use the variable tween
elsewhere, it would be easier to play the tween directly with TweenService:Create():Play()
optional:
instead of defining the variables and only using it once, why don’t you just merge it together in one line?
new script:
game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(5), {Orientation = Vector3.new(0, math.random(1, 360), 0)}:Play()
Yes i figured that out right after i posted this but ill give it to you
system
(system)
Closed
September 23, 2023, 8:35am
#9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.