Transition through two colors

I have a “voice command” through chat, it checks if you say a certain message and if you do then it changes a brick color

game.Players.PlayerAdded:Connect(function (player)
	player.Chatted:Connect(function(msg)
		if msg == "change" then
			print("ok")
			local oldColor = workspace.ColorPart
			workspace.ColorPart.Color = Color3.new(0.607843, 0.121569, 0)
			task.wait(5)
			workspace.ColorPart.Color = oldColor.Color
		end
	end)
end)

it changes the part color but its instantly, and I want it to basically transition the color to red.

I recommend looking into HSV and TweenService.
This code may work but I haven’t tested it.

local ColorToTweenTo = Color3.fromHSV(0,1,1) -- HSV is unnecessary here but it's good to know when working with colors
game:GetService("TweenService"):Create(workspace.ColorPart,TweenInfo.new(1,Enum.EasingStyle.Linear),{Color = ColorToTweenTo}):Play()

You could use the same code but for the other/original color as well.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.