Tween is not working or I doing it wrong?

Hello. I’m scripting a light script that will on command /lights turn off or turn on lights
I tween color3 of parts
Script:

local Lights = true
local Config = require(script.Configuration)
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "/lights" then
			if Config.CheckGroupRank == true then
				local PlayerRank = plr:GetRankInGroup(Config.GroupId)
				if PlayerRank >= Config.MinGroupRank then
					if Lights == true then
						for _,light in pairs(game.Workspace.Lights:GetChildren()) do
							local Tween = game:GetService("TweenService"):Create(light,TweenInfo.new(1.3,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Color = Color3.new(0,0,0)})
							Tween:Play()
						end
						Lights = false
					elseif Lights == false then
						for _,light in pairs(game.Workspace.Lights:GetChildren()) do
							local Tween = game:GetService("TweenService"):Create(light,TweenInfo.new(1.3,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Color = Color3.new(237, 234, 234)})
							Tween:Play()
						end
						Lights = true
					end
			end
		elseif Config.CheckGroupRank == false then
			if Lights == true then
						for _,light in pairs(game.Workspace.Lights:GetChildren()) do
							local Tween = game:GetService("TweenService"):Create(light,TweenInfo.new(1.3,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Color = Color3.new(0,0,0)})
							Tween:Play()
						end
						Lights = false
					elseif Lights == false then
						for _,light in pairs(game.Workspace.Lights:GetChildren()) do
							local Tween = game:GetService("TweenService"):Create(light,TweenInfo.new(1.3,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Color = Color3.new(237, 234, 234)})
					        Tween:Play()      
					       end
					Lights = true
			        end
			end
		end
	end)
end)

But this happen:

So I don’t know why it’s doing that
Thank for any help!

Color3.new() and basically all color3 properties scale between 0-1, setting it above 1 will result in these trippy results, try changing Color3.new() to Color3.fromRGB() and see if this will fix the issue.

1 Like