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.
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.
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.
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.
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.