Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Kicking script is giving me errors and not kicking the player?

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?

2 answers

✓ Accepted answer
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

1 comment

0

Thanks. I forgot that Kick is deprecated.

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)

1 comment

0

you didn't even change anything..

This discussion is preserved as it was. New answers, comments, and votes are closed.