Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
M9F 94
3 years ago

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

Log in to vote
1
Answered by 3 years ago

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.

0
Thank you sir! M9F 94 — 3y
Ad

Answer this question