Hello Zayadoo! The previous response WONT WORK! It violates filtering enabled. Instead, we can use a for loop to create a table of the humanoid instances and kill them all. All done on the server! Lets get started:
SETUP
- Create a local script under the button to kill all players
- Name the script "Detector"
- Create a remote event in ReplicatedStorage
- Create a script in server script service
Scripting
Detector local script:
killEV = game:GetService("ReplicatedStorage"):WaitForChild("KillAll")
script.Parent.MouseButton1Click:Connect(function()
killEV:FireServer()
end)
Receiver Server Script:
killEV = game:GetService("ReplicatedStorage"):WaitForChild("KillAll")
killEV.OnServerEvent:Connect(function(_)
local humanoids = {}
for _,v in pairs(game.Players:GetChildren()) do
if v.Character then
table.insert(humanoids, workspace:FindFirstChild(v.Name).Humanoid)
end
end
for _,v in pairs(humanoids) do
v.Health = 0
end
end)
Script Context
In the local script, we detect when the button is pressed and then fire an event based on that. We then recieve that in the server. From there, we use a for loop to get all of the current players humanoids and then use another loop to set all of the humanoids healths' to 0, thus killing them. With any questions/comments/concerns, please feel free to comment or reply to my post. ~mc3334
1 comment
Send a message to the server and then have the server fire it back to all clients to kill themselves