How to break or kill an object?

Hi, does anyone know how to delete an object from your game with a script. Essentially I’m trying to delete an item once it reaches a certain point. Thanks for reading this! :grinning_face_with_smiling_eyes:

1 Like

if you’re destroying a object, then its

OBJECT_NAME_HERE:Destroy()

For example,

Part:Destroy()
2 Likes

You don’t put the name of it, you put the path of it to the part.

1 Like

I think that what he meant cause you can’t really just put the name unless it’s a variable

1 Like

Hi here a simple part destroying script:

  1. Create a part
  2. Add a script into the part
  3. Script:

local part = script.Parent
part:Destroy()
workspace:Part:Destroy()

1 Like

Correct. You can define the part’s path with a variable and then use code I said.

You can use Debris for this

local Part = script.Parent
local Debris = game:GetService("Debris") -- getting Debris service

Debris:AddItem(Part, 8) -- (Thing you want to destroy, Time before it will be destroyed)
1 Like