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

how would i make this part destroy on touched when the parent has a value inside of it?

Asked by 4 years ago

im trying to make a part break from this touch function but i want to make it so that it will only break when the parent has a child inside of it called "break". this is the only way i know of doing it. any help?

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("break") then
        script.Parent:Destroy()
    end
end)
0
wdym break? kkfilms_1 68 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Your looking in the wrong area. hit is the part that touched your part. Your code should be this:

script.Parent.Touched:Connect(function(hit)
    if script.Parent:FindFirstChild("break") then
          script.Parent:Destroy()
    end
end)
0
no i want hit (part that touched the mainpart) to detect if the part has a child named "break" and if so then Destroy() 10x31x2019 -6 — 4y
0
elaborate kkfilms_1 68 — 4y
Ad

Answer this question