How do i gradually change the color of this?

this is my script and im trying to change the leave’s color to the new ones gradually

-- old ones
	local SetColorGrass = Terrain:SetMaterialColor(Enum.Material.Grass, Color3.fromRGB(67, 70, 36))
	local SetColorLG = Terrain:SetMaterialColor(Enum.Material.LeafyGrass, Color3.fromRGB(100, 94, 33))
	-- new ones
	local SetColorGrass = Terrain:SetMaterialColor(Enum.Material.Grass, Color3.fromRGB(121, 70, 11))
	local SetColorLG = Terrain:SetMaterialColor(Enum.Material.LeafyGrass, Color3.fromRGB(72, 41, 6))

also how do i make this shorter?

-- Ath
	wait(0.000001)
	Ath.Density = 0.32
	wait(0.000001)
	Ath.Density = 0.34
	wait(0.000001)
	Ath.Density = 0.36
	wait(0.000001)
	Ath.Density = 0.38
	wait(0.000001)
	Ath.Density = 0.4
	wait(0.000001)
	Ath.Density = 0.42
	wait(0.000001)
	Ath.Density = 0.44
	wait(0.000001)
	Ath.Density = 0.46
	wait(0.000001)
	Ath.Density = 0.48
	wait(0.000001)
	Ath.Density = 0.5
	wait(0.000001)
	Ath.Density = 0.52
	wait(0.000001)
	Ath.Density = 0.54
	-- End Ath

like instead of using so many lines it will just use a few

3 Likes

I think using a tween would work. You can find tutorials on YouTube on how to make tweens. Or look at the docs.

2 Likes

I don’t think that wait could “wait” for that amount of time. Try print(wait()) or print(task.wait())


Also use tweens for the love of god.

1 Like

As stated, wait() is the minimum time it’ll take for a wait to happen, which is one frame (1/60 th of a second or .0167 seconds).
You’re trying to change it in 0.000012 seconds, which is going to happen in only 1 frame, which is instant.
You should also use task.wait() instead since it replaced wait().

Here’s the link to the documentation on create.roblox.com for Tweens.
This will allow you to change the amount of time for a smooth transition from Ath.Density 0.32 to 0.54.

2 Likes