Trying to make a script where if an object named missile touches the brick, both the missile and brick removes.
1 | missile = workspace:FindFirstChild( "Missile" ) |
2 |
3 | function onTouched(hit) |
4 |
5 | --I dont know what to do here |
6 |
7 | end |
Help would be appreciated!
You don't need to find it in the workspace just find the name of the part that touched it.
1 | function MissileDetector(hit) --hit argument is the object that touched it |
2 | if hit.Name = = "Missile" then --If what touched it's name is missile then |
3 | --Do whatever you want |
4 | end |
5 | end |
6 |
7 | script.Parent.Touched:connect(MissileDetector) |
Tell me if it works. Don't forget to upvote and accept the answer.