Remote Event Kicking Everyone?

Hello, so I have a remote event that fires from the client to the server, and when the server reaches it… I want it to kick the player. This works fine except it kicks all the players…
Here’s the local script:

-- This would be a client local script
RemoteEvent:FireServer()

Server Script:

game.Players.PlayerAdded:Connect(function(plr)
RemoteEvent.OnServerEvent:Connect(function(Player)
   plr:kick("reason")
      end)
end)

-- I also tried
game.Players.PlayerAdded:Connect(function(plr)
RemoteEvent.OnServerEvent:Connect(function(Player)
   Player:kick("reason")
      end)
end)

The thing it is doesn’t kick me in studio when I use muti client test, but in the real game it would kick all players if one player triggered it, any help is appricated.

1 Like

You are able to locally kick the player, I believe, so there is no need for a remote event.

I don’t want to kick the local player, as they can hook the function kick() very easily, they can hook fire server too but I would rather use that.

Then why are you letting one client kick another? That could be a huge security risk for exploiters.

That’s not what’s happening, he’s letting the sever kick one client, but for some reason it’s kicking all…
@Mystery_Devx try fireing the kick for one player only the one calling the event.

100% fasle.

Only server sided can kick players.

Of course it does that because whenever a player joins your game, you’re assigning an event in which causes them to be kicked out of the server when the event is triggered by one client.

If you only want to kick a single player, then you should input some arguments when firing the event.

The client can kick only the local player. That’s what I was referring to.

1 Like

You shoud’ve phrased it better

How is it being triggered? Also when calling a triggered event, you don’t need a player join event. You can just do:

RemoteEvent.OnServerEvent:Connect(function(Player)
   Player:kick("reason")
end)

Yes thats the whole point of a remote event, to tell the server to kick the client.

Is there a button being pressed? Or a command? Or what?

Hello,
What you’ve done is make an event for whenever a player joins the game, it waits for an event and then kicks them. So if someone fire the remotevent all the past events will be fired, and each player kicked.
You don’t need to use a RemoteEvent to kick the local player, just fire it on game.Players.LocalPlayer.

That’s the opposite of what was asked. The post asked for a solution to the problem, which was the RemoteEvent kicking everyone when it was intended to kick one.

2 Likes

It’s when a player is exploiting, such as changes walkspeed.

right so just add the triggered event. Remove the player joined event

So just do what I quoted (charcount)

1 Like

The client can kick players.

game.Players.LocalPlayer:Kick("reason")

Or, if you want it on the server.

game.Players.PlayerAdded:Connect(function(player)
    player:Kick("reason")
end)
1 Like

Again, this function of local player kick can be hooked very easily, while as with fireserver() I can check if the event wasn’t fired and procced to do something else with the player.

1 Like

Or, if you want it as a remote event:

RemoteEvent.OnServerEvent:Connect(function(Player, target)
   game.Players:FindFirstChild(target):Kick("reason")
end)