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

How to make a script that removes a model after it's been placed?

Asked by 6 years ago

Hello.

I am trying to make this script I described above in the topic.

I wish to make a script that deletes the block I place in my game after a few seconds.

This model is called Grenade and it is placed in the workspace.

And this is the script I effortlessly tried to make it work:

local Part = Workspace.Grenade
wait (5)
Part:Destroy()
Part.Parent = Workspace

Thank you.

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The global variable Workspace is deprecated, you're looking for workspace. Use a ChildAdded event to listen for a child being added.

game.Workspace.ChildAdded:Connect(function(child)
    if child.Name == "Grenade" then
        wait(5)
        child:Destroy()
    end
end)
Ad
Log in to vote
0
Answered by
MrMedian 160
6 years ago
local Part = Workspace.Grenade
game:GetService("Debris"):AddItem(Part, 5)

Answer this question