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

How can I fix my auto-kick script so that it kicks anyone besides the owner?

Hello, I'm working on a script that will auto-kick anyone who isn't the owner of the game.

However, it isn't working. What am I doing wrong? This is my current code:

if game.Players.LocalPlayer.Name == "Phoenix_Ravin" then
print("Welcome Authorized Player!")
else
game.Players.LocalPlayer:Kick ("You are not an authorized player.")

It's a LocalScript inside of the Workspace.

1 answer

✓ Accepted answer

You're gonna want to add a Player Added function in a server script. Other than that, your script looks OK.

game.Players.PlayerAdded:Connect(function(player)
	if player.Name ~= "Phoenix_Ravin" then
		player:Kick("You are not an authorized player.")
	end
end)

5 comments

0

^^ Again make sure that's not a local script or it won't function correctly.

0

Or you could say: if player.UserId ~= game.CreatorId then. But this would only work in a real server. Not studio.

1

That worked, thanks!

1

^^ I don't have 25 reputation yet, so take my imaginary upvote.

0

Hope the upvotes help

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