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

Copied blocks won't get destroyed on touch?

Asked by 3 years ago
Edited 3 years ago

Here is my code:

EDIT: Changed the code to this, did not fix it.

function onTouched(hit)
    if hit.Name ~= "Slime" and hit.Name ~= "Baseplate" then
        if hit.Name == "Cannon Shot" then
            script.Parent.ExisHealth.Value = script.Parent.ExisHealth.Value - 1
            hit:remove()
        else
            hit:remove()
        end
    end
end

script.Parent.Touched:Connect(onTouched)

Basically if the slime ball hits a brick, it should destroy it. This works well, except when I copy a brick using a copy tool, or even copying in the Explorer while testing the game. The slime balls simply bounce off the copied brick without doing anything. They still will destroy/remove the original, but none of the copies.

Any suggestions?

0
please use :Destroy() instead of :remove() as it is deprecated RazzyPlayz 497 — 3y
0
I did try it with Destroy() and it had the same result, but I will use it from now on. pepsirune101112 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Maybe when you create another part you are forgetting to name it "Cannon Shot"

0
It is not supposed to destroy parts named Slime or Baseplate. pepsirune101112 0 — 3y
0
If the hit name is not Cannon shot, it is supposed to move down to next condition, that destroys it if it is named "Part: pepsirune101112 0 — 3y
Ad

Answer this question