Hi ScriptingHelpers!
Messing around with some ROBLOX programming and I've ran into a really strange interaction I can't figure out.
This is my code:
for i, v in pairs (game.Workspace.PlayBase.Plates:GetChildren()) do
local snum = string.sub(v.Name, 6)
local rnum = math.random(8500, 9500) * snum
local cl = Color3.fromRGB(rnum, rnum, rnum)
local cl2 = Color3.fromRGB(math.random(8500, 9500) * snum, math.random(8500, 9500) * snum, math.random(8500, 9500) * snum)
v.Color = cl2 -- OR cl.
end
PlayBase.Plates:GetChildren() are 25 plates which are set up in a 5x5 grid.This code is trying to set a random pattern of colours. The code works, but there's a catch.
When I choose to set v.Color to "cl2" the brick colour generates in the way that I would expect, as seen from this gyazo.
However when I set the v.Color to just "cl", which in my head is generated in EXACTLY the same way as cl2, you can see it does not act in the same way.
In my head cl and cl2 are generated in the same way, with a new Color3.fromRGB value, with the R, G, and B values being generated by "math.random(8500, 9500) * snum". Why are the outcomes consistently different? Am I missing something?

1 comment
What number does snum equal? RGB values only go up to 255 so snum must be a very low number?