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

Why's the location in workspace?!

script.Parent.Touched:connect(function()
	Instance.new("Explosion", game.Workspace.BlowPart)
	local Explosion = game.Workspace.BlowPart.Explosion
	game.Workspace.BlowPart:FindFirstChild("Humanoid")     
    Explosion.Position = script.Parent.Position
end)


I put an explosion instance in a Part named "BlowPart", I gave the explosion a Position too. So.. why when I touch the "BlowPart" it explodes.. BUT the workspace also explodes at (0, 0, 0)? I gave a CLEAR position. But it's exploding in two places at once. How do I fix this stupid glitch? Is it my computer? My studio?

Not to mention, the first time I touch the brick, it explodes I die, any other time after that, I don't die because for some reason, it's acting as if I'm giving the explosion two positions to transition from.

Output says:

12:08:20.179 - script.Parent.Touched:connect(function()
	Instance.new("Explosion", game.Workspace.BlowPart)
	local Explosion = game.Workspace.BlowPart.Explosion
	game.Workspace.BlowPart:FindFirstChild("Humanoid")     
    Explosion.Position = script.Parent.Position
end):1: attempt to index global 'script' (a nil value)

3 answers

✓ Accepted answer

Explosions explode as soon as they are in workspace. You're putting it in workspace on line 3. That's where it explodes. Lines 4 and 5 do nothing; it already exploded. Don't set the parent of the explosion until last.

3 comments

0

I thought I put it into the part on line 3? Right?

0

You have to give Instances Parents? I didn't know that.

0

The second argument of Instance.new is the Parent.

script.Parent.Touched:connect(function()
	local Explosion = Instance.new("Explosion")
	Explosion.Position = script.Parent.Position
	Explosion.Parent = game.Workspace.BlowPart
end)

--this is just so you understand what waffle was saying...

1 comment

0

IT WORKS!!! But.. what's the difference between THIS and what I put?

The above answers are probably correct, but Explosion.Position does not actually exist. Use Explosion.position instead.

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