Hey, so I’ve been working on a game where you get a block to avoid obstacles, and I want to add a way to make the block die after they hit the part. The part’s name is simply “Blok”, any help?
When you say:
You can add a Humanoid to it and damage the Humanoid so the part takes damage. Or you can use part:Destroy() which removes the part entirely from the game.
Do you mean like Portal’s emancipation grid, or do you mean that the part they get is what kills the player? I’m a bit confused.
I want to completely destroy it from the game when the “Blok” is touched by the killbrick
yeah i want to completely destroy the block
Still a bit confusing and I don’t know how you’re controlling that part, but you can either use the Touch event or GetPartsInParts to detect the touch, then use an if statement to see if the touch is the kill part, and if it is, use Destroy()
. But note that the Touch event won’t work if both parts are anchored.
So just add a touched event, check if it touched the Blok
, if it did Blok:Destroy()
its unanchored and the player can move the block
You would use part:Destroy() then
how do I put all of this into a script?
add script into the part and write
local part = --- wherever the part is located
part:Destroy()
example:
local part = workspace.Part -- stored in workspace and the part name is 'Part'
part:Destroy()
If you want to make it detect if a part get’s touched, but see what’s the parts name, if the part’s name matches exactly what you want, you can run :Destroy
()`.
You can implement it like this:
local blok = -- (DIRECTORY)
local event
event = blok.Touched:Connect(function(h)
if h.ClassName == "Part" or h.ClassName == "BasePart" then
if h.Name == "" then -- put what name is required for the main part to get destroyed.
event:Disconnect()
blok:Destroy()
end
end
end)
You can also use h:IsA(“BasePart”) instead of checking className for the several different types of parts.
I’m fully aware of that, I like using ClassName
.