Hello!
So I am currently working on a game, and there is this part. When the player touches the part, the sun begins to set, and the color of the Atmosphere and the ColorShifts Tween into a different color.
However, every time I run the game, it gives me an error saying “Unable to cast to Dictionary”.
17:21:53.149 Unable to cast to Dictionary - Server - NightObjectiveChangeScript:16
This is the Code:
print("Night Objective Change Script Start 1")
local NightObjectiveChangeEvent = game:GetService("ReplicatedStorage"):WaitForChild("NightObjectiveChangeEvent")
local NightObjectiveChangeEventAllClients = game:GetService("ReplicatedStorage"):WaitForChild("NightObjectiveChangeEventAllClients")
local Objective = game:GetService("ReplicatedStorage"):WaitForChild("Objective")
local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")
local Atmosphere = Lighting:WaitForChild("Atmosphere")
local ColorCorrection = Lighting:WaitForChild("ColorCorrection")
local LightingTween4 = TweenService:Create(Lighting, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { ClockTime = 17 })
local AtmosphereTween4 = TweenService:Create(Atmosphere, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Density = 0.4 })
local LightingColorShift_Bottom_TweenGoal = Color3.fromRGB(255, 206, 126)
local LightingColorShift_Bottom_Tween = TweenService:Create(Lighting.ColorShift_Bottom, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Color3.fromRGB(255, 206, 126) })
local LightingColorShift_Top_Tween = TweenService:Create(Lighting.ColorShift_Top, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Color3.fromRGB(255, 201, 115) })
local LightingOutdoorAmbient_Tween = TweenService:Create(Lighting.OutdoorAmbient, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Color3.fromRGB(204, 156, 79) })
local AtmosphereColorTween = TweenService:Create(Atmosphere.Color, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Color3.fromRGB(204, 156, 79) })
local AtmosphereDecayTween = TweenService:Create(Atmosphere.Decay, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Color3.fromRGB(199, 167, 94) })
local ColorCorrectionTintTween = TweenService:Create(ColorCorrection.TintColor, TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.In), { Color3.fromRGB(199, 167, 94) })
local Players = game:GetService("Players"):GetPlayers()
NightObjectiveChangeEvent.OnServerEvent:Connect(function()
print("Night Objective Change Script Start 2")
LightingTween4:Play()
AtmosphereTween4:Play()
LightingColorShift_Bottom_Tween:Play()
LightingColorShift_Top_Tween:Play()
AtmosphereColorTween:Play()
AtmosphereDecayTween:Play()
ColorCorrectionTintTween:Play()
wait(10)
Objective.Value = "Head back to your cabin"
NightObjectiveChangeEventAllClients:FireAllClients()
end)
The output says the problem is in the Tween Variables, so I have tried changing them around, but nothing seems to work. Can anybody help me?