New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do you do a 'Part-touch-Part' effect?

Asked by 6 years ago

Hey guys. I just have one simple question: How would you make a Part do an action when touched by another Part?

For example, let's just say that I have a part named GRASS and another part named MOWER. Whenever the player pushes the part named MOWER and it touches the other part named GRASS, GRASS becomes a different size. In this case, GRASS becomes smaller.

Would the general concept of it go something like this? :

function touch(hit)
    if hit.Name == "MOWER" then
        script.Parent.Size = Vector3.new(1,2,1)
    end
end
script.Parent.Touched:connect(touch)

If anyone could teach me, it would be very, very helpful!

1 answer

Log in to vote
1
Answered by 6 years ago

I don't love using the script.Parent kind of thing since I rarely put scripts in the Workspace (since anyone can access them without .FilteringEnabled on). Anyways, That looks pretty much as it should be.

Ad

Answer this question