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

How do i make block when character hits destroys another block ?

Asked by 3 years ago
Edited 3 years ago

i don't know programming too much so i tried this

script.Parent.Touched:connect(function(hit) 
    if hit and hit.Parent:FindFirstChild('Humanoid') then
        script.Parent:Destroy(game.Workspace.Trigger)
    end
end)

but it didnt work can someone help ???

1 answer

Log in to vote
0
Answered by 3 years ago

You have to create a variable for the part you want to destroy. So like this:

local Trigger = game.Workspace.Trigger
script.Parent.Touched:connect(function(hit) 
    if hit and hit.Parent:FindFirstChild('Humanoid') then
        Trigger:Destroy()
    end
end)

This should work and if it doesn't just let me know

0
Thank you it worked. yenen330 2 — 3y
0
Also I would like to add that the reason your script doesn't work and the part deletes itself is because you typed "script.Parent:Destroy" .When you type "script.Parent" you are referencing the part the script is in. So you don't have to create a variable, you can just replace the line you wrote with "script.Parent.Parent.Trigger:Destroy()". I prefer creating a variable though as you can use it la Traadess 67 — 3y
Ad

Answer this question