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

Explosion Script Doesn't Work? [Solved]

Asked by 10 years ago

for some reason, this script connects, destroys itself at the end, but doesn't actually insert the Explosion like it should. It works fine when r is false by the way.

-- cre is an object value
-- r is a Boolean value
function onHit(hit)
    if hit.Parent:FindFirstChild("Humanoid") and r.Value == false and hit.Parent.Name ~= cre.Value.Name then
        hit.Parent.Humanoid:TakeDamage(10)

    elseif r.Value == true and hit.Parent.Name ~= cre.Value.Name then
        local bo = Instance.new("Explosion")
        bo.BlastPressure = 10000
        bo.BlastRadius = 20
        bo.Parent = script.Parent
    end
    wait()
    script.Parent:Destroy()
end

1 answer

Log in to vote
1
Answered by
trogyssy 221 Moderation Voter
10 years ago

You need to set the position of the explosion, otherwise it'll go off at 0, 0, 0

-- cre is an object value
-- r is a Boolean value
function onHit(hit)
    if hit.Parent:FindFirstChild("Humanoid") and r.Value == false and hit.Parent.Name ~= cre.Value.Name then
        hit.Parent.Humanoid:TakeDamage(10)

    elseif r.Value == true and hit.Parent.Name ~= cre.Value.Name then
        local bo = Instance.new("Explosion")
        bo.BlastPressure = 10000
        bo.BlastRadius = 20
        bo.Parent = script.Parent
        bo.Position=script.Parent.Position
    end
    wait()
    script.Parent:Destroy()
end

0
Oh, is Position necessary for Explosions? I figured that was implied as it is with Fire, lights, etc. deaththerapy 60 — 10y
2
Yes it is needed. dyler3 1510 — 10y
Ad

Answer this question