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

How do I Make this Change The Shape of A Specific Brick?

Asked by 8 years ago

So, I have this script here, that changes the mesh of any brick that touches it. However, I do not know how to make it specific to a certain type of brick. For example, only when a brick called "Tycoon brick" touches it, it only effects that brick; and when bricks like those that are part of characters touch it, it does not change their shape. This is what I have to start, but I don't know how to make it brick specific.

z = script.Mesh 

function onTouched(part) 
z = z:clone() 
z.Parent = part  
end 
script.Parent.Touched:connect(onTouched)

Basically, the mesh is inside of this script, if that helps!

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

All you have to do is check the name of the part which touched with an if statement.

z = script.Mesh 

function onTouched(part) 
    if part.Name == "Tycoon brick" then
        z = z:Clone() 
        z.Parent = part  
    end
end 
script.Parent.Touched:connect(onTouched)

Hope this helped.

0
Yes Thank you!!! hurricanedog 0 — 8y
0
No problem. Pyrondon 2089 — 8y
Ad

Answer this question