Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

0

Thank you it worked.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.