I’m trying to make a game called "Illusions in the game some players may see things some may not. So this will involve alot of local scripts. Im trying to make a script where it kills everyone besides the local player.
How do I do this exactly? Or what do I connect the players with to the humanoid’s in the workspace
local PlayerNotToKill = PlayerObj
for _,plr in next, game:GetService("Players"):GetPlayers() do
if plr.Character and plr ~= PlayerNotToKill then plr.Character:BreakJoints() end
end
-- Script
local Event = Instance.new("RemoteEvent")
Event.Name = "KillAll"
Event.Parent = game.ReplicatedStorage
Event.OnServerEvent:Connect(function(plr)
for _,v in pairs(game.Players:GetPlayers()) do
if v.Name ~= plr.Name and v.Character then
v.Character:BreakJoints()
end
end
end)
-- Localscript
-- When something happens (i.e put this in an event or something)
local Event = game:GetService("ReplicatedStorage"):WaitForChild("KillAll")
wait(5)
if #game.Players:GetPlayers() > 1 then -- if there's more than 1 player in-game
Event:FireServer()
end
-- note this example will only kill the players once 5 seconds after the localplayer joins (assuming it's put in StarterPlayerScripts, which it should be), this is only example code and probably not the exact thing you're looking for.