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?
✓ ANSWER ACCEPTED
How to make a script that randomly selects a color to color a brick? [SOLVED]
3 answers
✓ Accepted answer
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)
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)
1 comment
0
On Wait(5.0) Change the 5.0 to what ever wait you want it to be.
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)
5 comments
0
I try to help and my rep goes lower...
0
Didn't work. I tried modifying it to "script.Parent.Brickcolor:random()" but that didn't work either-?
0
This answer is almost completely wrong.
0
It worked for me.
0
I fixed it.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Worked! Thanks so much!
No problem.