:Destroy() not working?

scripting
new-to-scripting
#1

I’m following the tutorial series of videos ROBLOX made a couple years ago and I followed their exact code to try and replicate what they’re doing. However, in the process of this I encountered that what the tutorial put in no longer works.

At 0:33 he creates a script for the bomb that causes it to explode after it has been created. However, when my bomb explodes it does not get deleted afterward. I checked for typos and errors multiple times and found nothing. Did ROBLOX change and deleting a part isn’t like this anymore?

wait(1)
local explosionPart = script.Parent
local explosion = Instance.new(“Explosion”)
explosion.Parent = game.Workspace
explosion.Position = explosionPart.Position
explosion()
wait(1)
explosionPart:Destroy()

There’s the script that goes inside of the bomb part.

local explosionPart = game.Workspace.pipebomb
local function createExplosionPartCopy()
local explosionPartCopy = explosionPart:Clone()
explosionPartCopy.Parent = game.Workspace
end
while true do
createExplosionPartCopy()
wait(1)
end

Here’s the script that goes inside ServerScriptStorage. Instead of the location of the part being inside ServerStorage, I just left it in the Workspace. I changed the lines referencing it’s location to match it being in the Workspace.

It’s a really basic and new question, and you could probably tell that I am new to scripting, so I would like for you to help me out. Thanks

#2

Make sure to post your script as well, No one will be able to help without seeing what you have in your script.

The code present in that video should work just fine, you may have just forgotten to call a function or something along the lines of that.

#3

I edited the post to add my scripts.

#4

Use codeblocks to make your code easier to read by adding ``` before and after your code

#6

what is “explosion()” suppose to do? Because unless you have something that is not posted there. You are trying to call a variable as a function???

#7

I may be mistaken, and the Documentation for class ‘Explosion’ is currently down so I can not double check, but doesn’t the explosion get fired automatically? Meaning calling the function explosion() [Line 6] would just result in an error?

Edit: I am aware I posted “Documentary” instead of “Documentation” above, ignore that. I haven’t had much sleep in the past few days.

#8

Yes, they do get called automatically. I’ve never even see explosion() and I know it is not a function of the explosion. Delete that line and it should be good. @VOKZ3L

#9

Ah yes, I forgot to mention that I added that line “explosion().”

It’s not included in the tutorial, but if I don’t have it there, when I run the game it only creates 2 explosion and then stops exploding. For some reason if I add that line it creates an infinite amount like it should, but it still doesn’t get deleted.

#10

Mind posting an .rbxl file to the place so we can get a better idea of the workflow throughout the file?

1 Like
#11

sdasaf.rbxl (33.8 KB)

#12

sdasaf.rbxl (33.9 KB)
Your issue was to do with the fact that you were using a reference part that was later being destroyed
I have fixed this by moving ‘pipebomb’ to ServerStorage, and cloning it to workspace for each explosion.

If this resolves all the issues present, please make sure to set this post as the Solution so other people do not come in here trying to help, just to see it is already solved.

#13

You fixed my issues. Thank you for the help.

#14

No problem, but as stated above make sure you set the post as the solution.

#15

Is there some checkbox to make it say solved, or do I just edit the title?

#16

There should be a faded checkmark on all posts (On the bottom bar of the post ,where you typically have options like Replying, liking, sharing, etc.) if you click it on the post that solved the issue then it will mark it as the solution.

like this for example:image
Clicking the Checkmark on the far left will mark it as the solution

#17

Alright, I figured it out. Again, thank you for the help.