✓ Accepted answer
Requote from my comment:
I'd use a for loop iterating through all the players.. :GetPlayers() would return a table, which you can't index a Name property at all
Here's a sample where you'd kill everyone except yourself.
script.Parent.MouseButton1Click:Connect(function()
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Name ~= 'ArcanZus' then
player.Character.Humanoid.Health = 0
end
end
end)
If we wanted this to work with FilteringEnabled, we'd use a RemoteEvent to make the server receive our request, and proceed with the task
local event = game:GetService("ReplicatedStorage"):WaitForChild("KillEveryone")
script.Parent.MouseButton1Click:Connect(function()
event:FireServer()
end)
((Separating both markups))
local event = Instance.new("RemoteEvent")
event.Name = 'KillEveryone'
event.Parent = game:GetService("ReplicatedStorage")
event.OnServerEvent:Connect(function(plr)
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Name ~= 'ArcanZus' then
player.Character.Humanoid.Health = 0
end
end
end)
2 comments
I'd use a for loop iterating through all the players.. :GetPlayers() would return a table, which you can't index a Name property at all
I'd suggest using a for loop after the function, ~= your name from the "Object" then kill them like that.