I've written the following code in an attempt to change the fire's color every time a player touches it:
local fire = script.Parent.Fire local rgb = math.random(0, 255) script.Parent.Touched:Connect(function(connect) if connect.Parent:FindFirstChild("Humanoid") then fire.Color = Color3.new(rgb/255,rgb/255,rgb/255) end end)
However, the function only changes the color once per play test. I'd like it to be able to change colors an unlimited amount of times, for every time a player touches the part.
You're practically there! The reason you may think the function only changes the color once per play test, is because you set the random value in the beginning of your code, which is outside of the event being triggered each time. Simple fix is to move it down!
I've taken the liberty of making your color even more random by randomizing each R, G, and B value. Also a quick tip, instead of dividing by 255, you can use Color3.fromRGB()
local fire = script.Parent.Fire script.Parent.Touched:Connect(function(connect) if connect.Parent:FindFirstChild("Humanoid") then fire.Color = Color3.fromRGB(math.random(0, 255),math.random(0, 255),math.random(0, 255)) end end)