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

How can I make this function delete Anchored Bricks?

Asked by
262187 45
9 years ago

I have a function that is suppose to remove bricks when it touches the brick with the function. How can I make it so the function will also delete anchored bricks?

Here's the script:

function onTouched(hit) 
if hit.Name == 'BuildingBrick' then
hit:Destroy()
end
end
script.Parent.Touched:connect(onTouched) 

1 answer

Log in to vote
3
Answered by
Unclear 1776 Moderation Voter
9 years ago

Just check for the Anchored property.

function onTouched(hit) 
if hit.Name == 'BuildingBrick' or hit.Anchored then -- also check if Anchored is true
hit:Destroy()
end
end
script.Parent.Touched:connect(onTouched) 

Ad

Answer this question