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

I can't make a brick switch materials?

local r = Workspace.Part
	
	function onTouch (part)
	
	r.Material = random ()

	wait (5)

end


a.Touched:connect(onTouch)

I am trying to get it so when you touch the brick it, it switches to a random Material. Can someone please tell me what is wrong here?

1 answer

✓ Accepted answer

Material values are strings. You can do this:

local r = Workspace.Part
function onTouch (part)
    r.Material = "Metal"
    wait (5)
end
a.Touched:connect(onTouch)

but there is nothing you can do to make it random automatically. You can do it using tables and math.random, though.

7 comments

0

Well how would I do that? I thought of it but I am a brginner so I have no idea how to. :(

0

I have a part that changes color and material whenever you touch it. You can get it and examine the code here:http://www.roblox.com/Improved-Lobby-Ball-item?id=139587781

0

Ok thank you

0

Oh it isnt a free model

0

When you find an answer, click "Accept Answer". It gives reputation to both you and the answerer!

0

I changed it to free. I thought that I set it to free, but then again, I made it about 9 months ago...

0

dangit when i use it its not showing up in the my models i need ur script

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