Here is my script, it's a server script.
local PcOn = script.Parent local rgb = PcOn.Parent.Parent.Case.rgbCables:GetChildren() -- rgb part local colors = {BrickColor.new("Steel blue").Color, BrickColor.new("Bright violet").Color, BrickColor.new("Magenta").Color, BrickColor.new("Neon orange").Color, BrickColor.new("Bright yellow").Color, BrickColor.new("Lime green").Color, BrickColor.new("Toothpaste").Color} local tweenService = game:GetService("TweenService") rgb.Material = ("Neon") function ColorChange(colorToChangeTo) local tweenInformation = TweenInfo.new(1) -- Time1 local ColorProperty = {} ColorProperty.Color = colorToChangeTo local tween = tweenService:Create(rgb,tweenInformation,ColorProperty) tween:Play() wait(1) -- Time2 end while true do if PcOn.Value == true then for i, v in ipairs(colors) do ColorChange(v) end end wait() end
It used to work but when I added the "while" loop at the end, it suddenly stopped working, even though I need the while loop to check the value of the BoolValue instance.
I get this error when the script runs:
21:40:33.919 Unable to cast value to Object - Server - RgbOn:24
21:40:33.919 Stack Begin - Studio
21:40:33.919 Script 'Workspace.PC.Motherboard.IsPcOn.RgbOn', Line 24 - function ColorChange - Studio - RgbOn:35
21:40:33.920 Script 'Workspace.PC.Motherboard.IsPcOn.RgbOn', Line 34 - Studio RgbOn:45
21:40:33.920 Stack End
All help is appreciated.