function OnPlayerEntered(plr) local pName = plr.Name if pName == "19under19" then --Kicking code plr:kick("You are banned from this game!") end end game.Players.PlayerAdded:connect (OnPlayerEntered)
This is the script I have in a server script in workspace. It is not kicking the player is it supposed to. Help?
function OnPlayerEntered(plr) local pName = plr.Name if pName == "19under19" then wait(1) plr:Kick("You are banned from this game!") end end game.Players.PlayerAdded:Connect(OnPlayerEntered)
I made 3 changes;
1. I added a wait(1) before kicking the player, Roblox has some things to do when a player joins, and if the player is removed before it's ready then it can cause some errors
2. I changed "connect" to "Connect" on the last line, "connect" is deprecated.
3. I changed "plr:kick" to "plr:Kick", I'm not 100% sure if it's deprecated but on the Roblox Wiki it's capitalized so why not
Please rate my comment correct.
function OnPlayerEntered(plr) local pName = plr.Name if pName == "19under19" then --[Kicking code]-- plr:kick("You are banned from this game!") end end game.Players.PlayerAdded:connect (OnPlayerEntered)