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

Explosion not spawning in the correct position?

Asked by 8 years ago

I've made a script where if the player touches the ground an explosion spawns in his head and he dies. But for some reason it spawns at 0,0,0 not the head position.

local part = script.Parent

part.Touched:connect(function(hit)
    local countdown = game.ReplicatedStorage:WaitForChild('Countdown')

    local character = hit.Parent
    local humanoid = hit.Parent:FindFirstChild('Humanoid')

    if humanoid and character and countdown.Value > 1 then
        Instance.new('Explosion', character.Head)
        humanoid.Health = 0
    end
end)

1 answer

Log in to vote
0
Answered by 8 years ago

You have to set the explosion's Position property. Just parenting the explosion to the character's head will not affect the position.

Instance.new('Explosion', character.Head).Position = character.Head.Position
0
Thanks alot! I tried something like that but set the position a line after as a new statement but it ended up not spawning. LifeInDevelopment 364 — 8y
Ad

Answer this question