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

Why can't I explode all players?

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

for i,v in pairs(game.Players:GetChildren()) do
            if v.Name ~= "bubb96" then -- add else
else
             Instance.new("Explosion",v.Character.Head)

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