I am writing a script for a realistic SOX style street light. They start glowing at a reddish colour and then shift to their normal warm yellowish light after a warmup period. I am trying to use tweens to shift the colours to that over the time given. Only that every time it attempts to tween it just returns a “Unable to cast to Dictionary” error. I’ve already tried looking things up but I’m still stumped as to what is incorrect. I’ve made tweens before that change colours but how come this one doesn’t want to work?
Here is the code that controls the light.
--Realistic LPS script by Almonty7655
local Bulb = script.Parent
local IsOn = Bulb.Parent.IsOn
local StartColor = Color3.fromRGB (255, 0, 21)
local OnColor = Color3.fromRGB(255, 115, 0)
local Casing = Bulb.Parent.LampCasing
local TweenService = game:GetService("TweenService")
function Start()
Bulb.Color = StartColor
Bulb.Light.Color = StartColor
Casing.Color = StartColor
Bulb.Material = "Neon"
Casing.Material = "Neon"
Bulb.Light.Enabled = true
Bulb.Transparency = 0
local tweenInformation = TweenInfo.new(
20,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local tween = TweenService:Create(Bulb.Color,tweenInformation,Color3.fromRGB(255, 115, 0))
local tween2 = TweenService:Create(Casing.Color,tweenInformation,Color3.fromRGB(255, 115, 0))
local tween3 = TweenService:Create(Bulb.Light.Color,tweenInformation,Color3.fromRGB(255, 115, 0))
tween:Play()
tween2:Play()
tween3:Play()
end
function Stop()
Bulb.BrickColor = BrickColor.new("Institutional white")
Casing.BrickColor = BrickColor.new("Institutional white")
Bulb.Light.Enabled = false
Bulb.Material = "SmoothPlastic"
Casing.Material = "SmoothPlastic"
Bulb.Transparency = 0.5
end
function Control()
if IsOn.Value == true then
Start()
else
Stop()
end
end
IsOn.Changed:Connect(Control)