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

Why does my Instance spawn in the Workspace?

script.Parent.Touched:connect(function(hit)
	if hit.Name == "Left Leg" then
	script.Parent = Instance.new("Explosion",game.Workspace.Part).ExplosionType == "CratersAndDebris"
   end
end)

So, this is kind of self explanitory, but i'll explain anyway.

I want the part to explode when someone touches it, but.. the Explosion instance spawns in the workspace.. why is that?

1 answer

✓ Accepted answer

Explosions have a Position property. If you don't set the Position, it uses (0, 0, 0).

local exp = Instance.new("Explosion", workspace.Part)
exp.ExplosionType = "CratersAndDebris"
-- Set the position:
exp.Position = workspace.Part.Position

4 comments

0

Wait.. didn't you forget the game? Right before you put Workspace.Part.Position, you forgot game, right? Or is it supposed to be like that?

0

No. It's supposed to be like that. workspace is a variable that's provided for you the same way that game is.

0

Uhm, It works except that it explodes the brick AND workspace at (0, 0, 0) and idk why because NOWHERE in my script it says to put an explosion instance into workspace. I gave it a specific location. It explodes at that location AND workspace. How do I fix that?

0

You must have two different scripts going on. Did you Copy + Paste anything and forget about it?

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