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

Why does my Instance spawn in the Workspace?

Asked by 9 years ago
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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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
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? james24dj 90 — 9y
0
No. It's supposed to be like that. `workspace` is a variable that's provided for you the same way that `game` is. BlueTaslem 18071 — 9y
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? james24dj 90 — 9y
0
You must have two different scripts going on. Did you Copy + Paste anything and forget about it? BlueTaslem 18071 — 9y
Ad

Answer this question