Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to change a bricks color within a specific color range with no luck? I accept answers

Heres my code, it should be pretty easy to understand what I'm trying to get done. The code works just I don't know why my player is being turned completely white and not somewhat in the range of green. My problem definitely with the math.Randoms

local zombieZombieTone = Instance.new("BodyColors")
zombieZombieTone.Name = ("Zombie Colors")
zombieZombieTone.Parent = hit.Parent
local zombieToneParts = {"HeadColor", "LeftArmColor", "LeftLegColor", "RightArmColor", "RightLegColor", "TorsoColor"}

for y, u in pairs(zombieToneParts) do
	hit.Parent["Zombie Colors"][u] = BrickColor.new(math.random(0, 130), math.random(158, 164), math.random(0, 130))
end		

1 answer

✓ Accepted answer

This is a common case of misunderstanding BrickColor.new. BrickColor.new (as well as Color3.new) actually doesn't take arguments in ranges of 0 to 255. BrickColor.new expects a number between 0 and 1. Going over or under can cause unpredictable results.

If you want to use a range of 0 to 255, then your best option would be to use replace the argument in the BrickColor.new with a Color3 using a Color3.fromRGB, NOT Color3.new.

1 comment

0

Thank you sir!

This discussion is preserved as it was. New answers, comments, and votes are closed.