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

Why's the location in workspace?!

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

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

0
I thought I put it into the part on line 3? Right? james24dj 90 — 9y
0
You have to give Instances Parents? I didn't know that. james24dj 90 — 9y
0
The second argument of Instance.new is the Parent. 1waffle1 2908 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
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...

0
IT WORKS!!! But.. what's the difference between THIS and what I put? james24dj 90 — 9y
Log in to vote
0
Answered by 9 years ago

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

Answer this question