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

How do i make A brick change transparency when A brick touches it? [closed]

Asked by 8 years ago

So i have a tool to throw a ball and i have a brick. Now i want the brick to be transparent when the ball touches it. I'm not a very good scripter but i know that it has something to do with the TouchedEvent. I would appreciate any help. Thanks...

Closed as Not Constructive by Sublimus, Pyrondon, and M39a9am3R

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 8 years ago
function whenTouched(part)
    if part.Name = "Name of the Ball" then
        local x = script.Parent
        x.Transparency = 1

    end
end

script.Parent.Touched:connect(whenTouched)

This script will allow the brick to change transparency when the ball (any other brick will not work) touches the surface of the brick. On the if part.Name = "Name of the Ball" line of code, change the text inside the speech marks to the name of the ball on the workspace or where ever it is located, if it is Ball then your code would be

function whenTouched(part)
    if part.Name = "Ball" then
        local x = script.Parent
        x.Transparency = 1

    end
end

script.Parent.Touched:connect(whenTouched)

Hope this works. Remember to insert this code in to a normal script, which should be inside the brick that you want to become transparent.

Ad