How to find the name of the keypoint

(Sorry for bad title)
Hi
I got this function from a very nice guy which returns be a color3 but I want it to return color3 and the name of the color

local biomeColours =
	{
		["sand"] = Color3.fromRGB (239, 240, 147),
		["grass"] = Color3.fromRGB (159, 226, 87),
		["forest"] = Color3.fromRGB (116, 130, 46),
		["snow"] = Color3.fromRGB (203, 203, 203)
	}

local terrainColorSequence = ColorSequence.new{
	ColorSequenceKeypoint.new(0, biomeColours["sand"]),
	ColorSequenceKeypoint.new(0.5, biomeColours["grass"]),
	ColorSequenceKeypoint.new(0.7, biomeColours["forest"]),
	ColorSequenceKeypoint.new(1, biomeColours["snow"]),
}

function evalCS(cs, time)
	if time == 0 then return cs.Keypoints[1].Value end
	if time == 1 then return cs.Keypoints[#cs.Keypoints].Value end
	for i = 1, #cs.Keypoints - 1 do
		local this = cs.Keypoints[i]
		local next = cs.Keypoints[i + 1]
		if time >= this.Time and time < next.Time then
			local alpha = (time - this.Time) / (next.Time - this.Time)
			local color = Color3.new(
				(next.Value.R - this.Value.R) * alpha + this.Value.R,
				(next.Value.G - this.Value.G) * alpha + this.Value.G,
				(next.Value.B - this.Value.B) * alpha + this.Value.B
			)
				
			local biome = -- idk
			
			return color, biome
		end
	end
end

So it should return something like this: 0.639886, 0.889137, 0.353444, “sand”

This one actually made me think a bit, but, you would simply use a for loop and check if it is the same.

local biome = nil
local times = 0
for a,v in pairs(biomeColours) do
	times += 1
	if times == i then
		biome = a
	end
end
1 Like