Title. Haven’t found anyone cover this.
Insert a part, apply the Neon material, add a script to the part with code that changes the BrickColor property over time using the HSV color model, and playtest the game to see the animated rainbow effect Xx
Could you kindly show me how that works, I’ve never used this HSV model before. Thank you :D_
The HSV color model in Roblox represents colors based on hue, saturation, and value, and by modifying the hue component over time using a script, you can create an animated rainbow effect on a part. Here’s a code example Xx
local part = script.Parent
local hue = 0
local hueIncrement = 0.01
while true do
wait(0.1)
hue = hue + hueIncrement
if hue >= 1 then
hue = 0
end
part.BrickColor = BrickColor.new().HSV(hue, 1, 1)
end
'HSV' is not a valid member of BrickColor
Fixed your code and made it look a bit seamless.
local part = script.Parent -- ur part here
local hue = 0
local hueIncrement = 0.005 -- adjust for color speed
game:GetService("RunService").Heartbeat:Connect(function()
hue = hue + hueIncrement
if hue >= 1 then
hue = 0
end
local r, g, b = Color3.fromHSV(hue, 1, 1):ToHSV()
local color = Color3.fromHSV((hue + hueIncrement) % 1, 1, 1):Lerp(Color3.new(r, g, b), hue % (1 / hueIncrement))
part.BrickColor = BrickColor.new(color)
end)
Actually I made my own, here’s a (probably) better and more simple code:
local b = script.Parent
local x = 0
while true do
b.Color = Color3.fromHSV(x,1,1)
x = x + 1/255
if x >=1 then
x=0
end
task.wait()
end
while true do task.wait() end
is the equivalent to using heartbeat
.
Glad you could figure it out yourself. Good luck.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.