I tried looking around but did not find anything helpful. Especially the stupid roblox documentation. Ever since they removed a lot of the examples and made it way harder to understand for no reason, I cant find jack. IF anyone can help that would be nice. Thanks
local function evalColorSequence(sequence: ColorSequence, time: number)
-- If time is 0 or 1, return the first or last value respectively
if time == 0 then
return sequence.Keypoints[1].Value
elseif time == 1 then
return sequence.Keypoints[#sequence.Keypoints].Value
end
-- Otherwise, step through each sequential pair of keypoints
for i = 1, #sequence.Keypoints - 1 do
local thisKeypoint = sequence.Keypoints[i]
local nextKeypoint = sequence.Keypoints[i + 1]
if time >= thisKeypoint.Time and time < nextKeypoint.Time then
-- Calculate how far alpha lies between the points
local alpha = (time - thisKeypoint.Time) / (nextKeypoint.Time - thisKeypoint.Time)
-- Evaluate the real value between the points using alpha
return Color3.new(
(nextKeypoint.Value.R - thisKeypoint.Value.R) * alpha + thisKeypoint.Value.R,
(nextKeypoint.Value.G - thisKeypoint.Value.G) * alpha + thisKeypoint.Value.G,
(nextKeypoint.Value.B - thisKeypoint.Value.B) * alpha + thisKeypoint.Value.B
)
end
end
end
local colorSequence = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
ColorSequenceKeypoint.new(0.5, Color3.fromRGB(0, 190, 200)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(190, 0, 255))
}
print(evalColorSequence(colorSequence, 0.75)) --> 0.372549, 0.372549, 0.892157
The reason why is because you’ll need to ”tell” the ColorSequence what time the color you want to use is present inside of it
I got this function from the docs here:
I agree the docs can be hit-or-miss on how well it explains certain properties and functions, but sometimes the info is there but hard to find or easy to accidentally miss
11:02:42.664 KeyPoints is not a valid member of Beam
I still dont understand. I see keypoints being used and im trying to use keypoints but its not working. I just want to set my value to the color of my beam. There has to be something much more simpler than doing all that just to set my value once?
Unfortunately since Beams use a ColorSequence for their color property, you will need to use the function unless the color you’d like to retrieve happens to be at exactly 0 or 1 time
This is why I loathe using Sequences and prefer using Curves, but in this case there isn’t a choice unfortunately since the property only accepts Sequences
To set the value of a Color3Value using a BEAM, you can simply do:
local lightBeam = game.Workspace.Part.Beam;
local newVal = Instance.new("Color3Value")
print(lightBeam.Color.Keypoints[1].Value)
newVal.Value = lightBeam.Color.Keypoints[1].Value --This will get the first keypoint color and set it to the corresponding value.
--do something:
lightBeam.Color = ColorSequence.new(newVal.Value)
This is just a basic way of achieving this. Of course there are multiple other ways of going about this.