Help with using tween service

im trying to script a color changing part with tween service using math.random but the issue its only tweening any 2 same colors repeatedly, i want it to tween random colors everytime any fixes?

local part = script.Parent
local TweeningInformation = TweenInfo.new(
 0.5,
 Enum.EasingStyle.Quad,
 Enum.EasingDirection.Out,
 753475938457843579348573,
 true,
 0
)

local PartProperties = {
 Color = Color3.fromRGB(math.random (0,255), math.random (0,255), math.random (0,255) )
}

local Tween = TweenService:Create(part,TweeningInformation,PartProperties)
Tween:Play()
1 Like

Use a loop to randomize the color instead:

while wait(.5) do
	local Tween = TweenService:Create(part,TweeningInformation, {Color = Color3.fromRGB(math.random (0,255), math.random (0,255), math.random (0,255))})
	Tween:Play()
end
1 Like

for the future, change that massive number to -1 if you want it to be infinite

might be better to use

local TweeningInformation = TweenInfo.new(
 0.5,
 Enum.EasingStyle.Quad,
 Enum.EasingDirection.Out,
 0,
 true,
 0
)

while true do
	local Tween = TweenService:Create(part,TweeningInformation, {Color = Color3.fromRGB(math.random (0,255), math.random (0,255), math.random (0,255))})
	Tween:Play()

	Tween.Completed:Wait()
	-- or
	task.wait(.5)
end

2 Likes
local ts = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1) --speed
local part = script.Parent
local tween, randomColor

while true do
	randomColor = Color3.fromRGB(
		math.random(0, 255), math.random(0, 255), math.random(0, 255))
	tween = ts:Create(part, tweenInfo, {Color = randomColor})
	tween:Play() tween.Completed:Wait()
end
2 Likes

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