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

I can't make a brick switch materials?

Asked by 10 years ago
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

Log in to vote
0
Answered by 10 years ago

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.

0
Well how would I do that? I thought of it but I am a brginner so I have no idea how to. :( noob1126 34 — 10y
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 User#348 0 — 10y
0
Ok thank you noob1126 34 — 10y
0
Oh it isnt a free model noob1126 34 — 10y
View all comments (3 more)
0
When you find an answer, click "Accept Answer". It gives reputation to both you and the answerer! User#348 0 — 10y
0
I changed it to free. I thought that I set it to free, but then again, I made it about 9 months ago... User#348 0 — 10y
0
dangit when i use it its not showing up in the my models i need ur script kingofpronoobs 0 — 6y
Ad

Answer this question