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

Explosion Script Doesn't Work? [Solved]

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

✓ Accepted answer

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

2 comments

0

Oh, is Position necessary for Explosions? I figured that was implied as it is with Fire, lights, etc.

2

Yes it is needed.

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