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

How to make a script that randomly selects a color to color a brick? [SOLVED]

Asked by 10 years ago

I have a brick that becomes visible on humanoid touch, but I want the color of the brick to be random on humanoid touch as well. Any help?

3 answers

Log in to vote
2
Answered by
Hybric 271 Moderation Voter
10 years ago
function Hybric(hit)
local g = hit.Parent:findFirstChild("Humanoid")
if (g ~= nil) then
Workspace.Part.Color = Color3.new(math.random(), math.random(), math.random())
end
end

script.Parent.Touched:connect(Hybric)
0
Worked! Thanks so much! DrCylonide 158 — 10y
0
No problem. Hybric 271 — 10y
Ad
Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
10 years ago

Well what you are saying when a Humanoid touches it well I dont know how to make it only when a Humanoid touches it but I can do when anything touches it.

function onTouched (hit)
    script.Parent.BrickColor = BrickColor.Random()
wait(5.0)   
end

script.Parent.touched:connect(onTouched)
0
On Wait(5.0) Change the 5.0 to what ever wait you want it to be. IcyEvil 260 — 10y
Log in to vote
-1
Answered by
Kozero 120
10 years ago

Here,This random() method is used to set a random value out of the available not including nil and to do that we use the event function that activates it.

function Touched(hit)
if hit.Parent:findFirstChild("Humanoid")  then
Workspace.Part.BrickColor:random()
end
end
script.Part.Touched:connect(Touched)
0
I try to help and my rep goes lower... Kozero 120 — 10y
0
Didn't work. I tried modifying it to "script.Parent.Brickcolor:random()" but that didn't work either-? DrCylonide 158 — 10y
0
This answer is almost completely wrong. duckwit 1404 — 10y
0
It worked for me. Kozero 120 — 10y
0
I fixed it. Kozero 120 — 10y

Answer this question