Script wont kick all players [SOLVED]

When a team loses all players everybody should get kicked, but it is not working.

image

image

image

bump ------------------------------

1 Like

This is a very BAD WAY of checking if all players of a team died. Exploiters can fire a RemoteEvent at any time with their executors.

You must check the amount of players via the server, not the client. I also recommend you changing your while true do loop to while true and wait() do, else you will get a script timeout error.

1 Like

but it’s in replicated storage

1 Like

image

and isn’t this checking the server

and that is in a server script aswell

Instead of using:

while true do
   --code
end

You can do:

while wait() do
   --code
end

ok but will that fix the problem

It will. Doing the while true do method will not work because you don’t have any boolean value set to true.

It still doesnt work --------------------

It doesnt print anything either, even though i added prints

On the local script, you reference the event to replicatedStorage on the local script. Make sure that it is referring to the actual event that is in replicated storage.

it is -------------------------------

the loop doesn’t even print stuff anymore

LocalScript:

local death = script.Parent
local event = script.RemoteEvent

while task.wait(1) do
    print('Running Loop')
    if death.Value < 0 or death.Value == 0 then
         event:FireServer()
    end
end

ServerScript:

local event = script.Parent
local death = game.ReplicatedStorage:WaitForChild("DeathPoll2")
event.OnServerEvent:Connect(function(player)
    print(death)
    for i,v in pairs(game:GetService("Players"):GetPlayers()) do
         v:Kick("Game Ended, You killed the Enemy Team Successfuly.")
    end
end)

This should work notify me if not, and send the errors

ok I will try this ------------

This is false, do you know any scripting? no offense.

true will always returns true so it acts like a boolean that is enabled/is true.

yes I know scripting -----------

I was talking to @glwwinnq, didnt mean you.

It still doesn’t work ---------