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

Explosion not positioning itself?? [SOLVED]

I have solved the question! I found that I was using the nil bomb to set the position when I should've used the newbomb. Thanks for trying!

4 comments

0

Line 22 is NOT being ignored! Code within '--' (comments) will be ignored, otherwise, it is not possible. Also, have you tried putting line 22 before 21? Lastly, there is no need to use 'AddItem', 'Explosion''s remove themselves after they have 'exploded'. (Sorry if I sound harsh or rude :(  )

0

As the Lua 5.2 Programming book states: 'Lua attempts to run a chunk of code all at the same time, as if it's in one line', however, it does each one at a time, thus your problem, it is executing each line before the position, I just wanted to clear this up so that you could understand my other comment. :P

0

@TheAlphaStigma Explosions don't really remove themselves, they just do nothing. But they can cause lag if there are a lot in workspace.

0

That is not really true, depending on how you use an Explosion, it can damage a Player's Health, but, after it had exploded, it removes itself.

2 answers

Explosions disappear shortly after they are placed into workspace. You are doing

Local ex = Instance.new("Explosion", workspace) -- immediatly setting the parent
ex.BlastPressure = 0
ex.BlastRadius = 35

The explosion doesnt have enough time to set its properties since it immediately gets destroyed when you create it Instead set the parent of the explosion after you've set the properties and it should work!

Local ex = Instance.new("Explosion")
ex.BlastPressure = 0
ex.BlastRadius = 35
ex.Parent = workspace

2 comments

0

Thaumic, that isn't the problem. The problem is it won't position the explosion. The explosion exists until I tell the script to remove it. But explosions DO NOT remove themselves! All they do is after exploding, they go into an "Idle" mode which can cause lag if there are a lot of them. So I delete the explosions to prevent all the lag. I've used the "Instance.new("Explosion", workspace)" before.

1

Quoting from the wiki (http://wiki.roblox.com/index.php?title=Explosion): "They disappear shortly after creation if placed in the Workspace, and delete themselves.". Tested this and it is true.

As I have Answered from my comments; Line 22 is not being 'ignored' as you assume, comments (The green '--' dashes/things), to lua, tell the code which code or chunk to ignore (or not run that code, in other words).

Also answered by my comments, your problem is that it is creating the Explosion, but, setting the Position AFTER it had exploded, as I have pointed out; "As the Lua 5.2 Programming book states: 'Lua attempts to run a chunk of code all at the same time, as if it's in one line', however, it does each one at a time." As it says, lua can not execute everything at once, no program can (no program that I'm aware of, that is) automatically execute everything at once on execution of the chunk, it can only execute each code individually, however, lua automatically (attempts) to run the code on execution of the chunk, so that it does give this effect, however, the reality is that lua is running each line of code separately, even putting the code in one line, it still applies as running each code (chunk) individually.

So, how to fix the code? Just set the code up so that the Position is set before the Child (Instance, or the explosion) has spawned;

-- This is an Example code, I am too tired to check your entire code for anymore errors and such, sorry. :(
local Explosion = Instance.new("Explosion") --Do not put anything for the optional Argument; Leave it as it; Variable 'Explosion' is specifying the new 'Explosion' instance
Explosion.Position = Vector3.new(math.random(50),math.random(50),math.random(50)) --This will set the 'Explosion''s Position property (the newly created explosion) to a Random Position (Random Vector3 Position)
Explosion.Parent = game.Workspace --Now, when we set the 'Explosion''s Parent to 'game.Workspace', you'll see that it is a random spot (Position) each time

Sorry if this Answer sounds harsh, rude, or not-so-well explained, I started typing this while I was very tired. :(

Hope this helped at all!

3 comments

0

TheAlpha, that is not the case. It didn't work without the comment. What you see in the chunk of code is not the comment. If it were the comment then the whole line would be green. But because of how ScriptingHelpers is set up, when I put the comment and kept typing, it went to the next line because the comment wasn't able to fit in one line. Sorry, but this is not the solution. I might actually h

0

In my Answer, I explained that Comments are used to Ignore certain codes (chunks), I did not even say it was Comments causing the problem, it was that the Explosion wen't off before you set the Position (as I explained in my Answer).

0

I found out that I was using the wrong variable to position the explosion. I set the explosion's position to where the nil bomb was.

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