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

Why won't my BrickColor be random?

Asked by 5 years ago
Edited 5 years ago
local Owner
local colors = {"Medium stone grey","Sea green","Really red"}

while true do
    Owner = script.Parent.Parent.owner
    if Owner.Value ~= nil then
    local original = script.Parent.Party1
    local copy = original:Clone()
    copy.Parent = script.Parent.Parent.Parties
    copy.Transparency = 0
    copy.CanCollide = true
    copy.Anchored = false
    copy.Position = Vector3.new(129.5, 8.5, -16.25)
    copy.BrickColor = BrickColor.new(colors[math.random(1, 3)])
    wait(1)
    end
    wait()
end
0
do you want a whole spectrum of colors or just those three? DeceptiveCaster 3761 — 5y
0
you can just do Brickcolor.Random() theking48989987 2147 — 5y
0
just those 3 PaliKai13 92 — 5y
0
idk if that's the correct capitalization :P theking48989987 2147 — 5y
View all comments (2 more)
0
It is PaliKai13 92 — 5y
0
setting the Parent first might be causing lag DeceptiveCaster 3761 — 5y

2 answers

Log in to vote
2
Answered by
Thetacah 712 Moderation Voter
5 years ago
Edited 5 years ago

Hi!

It was expecting a BrickColor value, but you gave it a String value!

Simple fix!

copy.BrickColor = BrickColor.new(colors[math.random(1, 3)]) --This is what your BrickColor line should look like

What you were essentially doing:

copy.BrickColor = "ColorHere" --Incorrect

What its doing now:

copy.BrickColor = BrickColor.new("BrickColorHere") --Correct
0
didn't work... PaliKai13 92 — 5y
0
Color3.fromRGB is guaranteed to work, sometimes BrickColor doesn't accept strings DeceptiveCaster 3761 — 5y
0
I tested it in Studio...It is working as advertised. Thetacah 712 — 5y
0
*ahem* if strings don't work use numbers DeceptiveCaster 3761 — 5y
View all comments (6 more)
0
No need for that. The code I posted works perfectly fine(Just as much as using Color3.fromRGB would).  Thetacah 712 — 5y
0
I don't get it. It doesn't work PaliKai13 92 — 5y
0
Are you receiving any errors in output? Thetacah 712 — 5y
0
DERR. I figured it out, I had a texture on it, it was a meshpart PaliKai13 92 — 5y
0
you could just use Brickcolor.Random() theking48989987 2147 — 5y
Ad
Log in to vote
1
Answered by 5 years ago

just do

BrickColor.Random()

Answer this question