I'm attempting to make a brick that has a function and when "BuildingBrick" touches it, it will delete. The function works but only for un-anchored "BuildingBrick". How would I make the function un-anchor the part(BuildingBrick) and destroy it when it touches the brick with the script? Edit: I'm using CFraming.
What I attempted to do:
function onTouched(hit)
if hit.Name == 'BuildingBrick' and hit.Anchored then
hit.Anchored = false
hit:Destroy()
end
end
script.Parent.Touched:connect(onTouched)
I've also tried
function onTouched(hit)
if hit.Name == 'BuildingBrick' or hit.Anchored then
hit:Destroy()
end
end
script.Parent.Touched:connect(onTouched)
and it dosen't work

7 comments
Are you CFraming BuildingBrick towards the other brick?
Yes.
Ok, look here: http://wiki.roblox.com/index.php?title=Touched Under the notes section, it states, that the touched event will not fire if a brick is being cframed through another brick
Ah, So this is just not possible?
Well it is, but you might need to do it a different way. An example would be to use a script to find all the edges of each block, and from there use a Changed() event to find out whether they're touching whenever the part is moved. There's probably more efficient ways to do it, but this is just an example.
Oh, I see Thanks!
Np :P