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

Why can't I explode all players?

Asked by
jqrx 0
9 years ago

I'm trying to make my script explode everyone except me. It only puts the explosion in the base?

player = game.Players.LocalPlayer
char = player.Character
mouse = player:GetMouse()
function shoot()
    local b = Instance.new("Part",workspace)
    b.Anchored = true
    b.CFrame = char.Torso.CFrame * CFrame.new(0,0,-1)
    b.Material = Enum.Material.Neon
    b.Shape = "Ball"
    b.Size = Vector3.new(3,3,3)
    b.Touched:connect(function(hit)
        if hit.Parent.Name == "bubb96" then
            return
        else
            hit.Parent:BreakJoints()
        end
    end)
    for i = 1, 70 do
        wait()
        b.Position = b.Position + Vector3.new(2,0,0);
    end
end
mouse.KeyDown:connect(function(key)
    if key == "z" then
        shoot()
    elseif key == "x" then
        for i,v in pairs(game.Players:GetChildren()) do
            if v.Name ~= "bubb96" then
                Instance.new("Explosion",v.Character.Head)
                wait(0.5)
            end
        end
    end
end)

Help would be appreciated.

1 answer

Log in to vote
0
Answered by
Decemus 141
9 years ago
for i,v in pairs(game.Players:GetChildren()) do
            if v.Name ~= "bubb96" then -- add else
else
             Instance.new("Explosion",v.Character.Head)
Ad

Answer this question