Superr_Z
(Superr_Z)
September 19, 2022, 4:15am
#1
I’m trying to smoothly change the clocktime from 14.5 to 3 using this code
local TweenService = game:GetService("TweenService")
local CycleTime = 10
local Frames = 100
local Clocktime = game.Lighting.ClockTime
local Info = TweenInfo.new(
CycleTime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
Frames,
false,
0
)
local NightGoal = Clocktime == 3
local SetClockToNight = TweenService:Create(Clocktime, Info, NightGoal) ---Where I'm getting my error
wait(10)
SetClockToNight:Play()
In the output tab I’m getting " Unable to cast to Dictionary " line 22 which is the SetClockToNight line
Can someone explain why I’m getting this error please? Thanks
Forummer
(Forummer)
September 19, 2022, 4:18am
#2
local NightGoal = Clocktime == 3
local NightGoal = {ClockTime = 3}
‘goal’ parameter should be a dictionary of properties and values.
TweenService:Create(game.Lighting, Info, NightGoal)
1 Like
jufdnhf
(jufdnhf)
September 19, 2022, 4:19am
#3
You need to put in the Instance you are tweening as the first argument of TweenService:Create()
, so you wouldn’t do TweenService:Create(ClockTime)
, you’d do TweenService:Create(Lighting, Info, {ClockTime = 3})
Superr_Z
(Superr_Z)
September 19, 2022, 4:22am
#4
I did this and now I’m getting unable to cast value to object
Forummer
(Forummer)
September 19, 2022, 4:23am
#5
Make sure the first argument is game.Lighting
or a variable which is a reference to the ‘Lighting’ service also ‘Clocktime’ needs to be ‘ClockTime’.
1 Like