Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do i fix my destroy brick?

Asked by 13 days ago

i have a brick with a script like this:

script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        wait(.1)
        hit.Parent.Humanoid.Health = 0
    else
        hit.Destroy()
    end
end)

but whenever something besides a humanoid touches it it wont destroy it

please help

0
Do you want it to be only a player can touch it? Or any object? PoppyandNeivaarecute 22 — 13d
0
If your looking to make a script that kills a player then try this iNykoda -1 — 13d
0
FE? AidanTES -6 — 13d

1 answer

Log in to vote
0
Answered by 13 days ago
Edited 12 days ago

I don't know why your script isn't working, it might be with the way you wrote it. But i rewrote it this way and it works.

function touched(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    else
        hit:destroy()
    end
end
script.Parent.Touched:Connect(touched)
0
:Remove() is deprecated use :Destroy(). Rheines 489 — 13d
0
it seems to work know Thank you CubicleHead -1 — 12d
0
also how can i make a object unremovable? CubicleHead -1 — 12d
0
You could maybe use an if statement before destroying the object, if it has a specific property it doesnt destroy. orangebuddycrash 57 — 12d
Ad

Answer this question