Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)
0
^^ Again make sure that's not a local script or it won't function correctly. namespace25 594 — 4y
0
Or you could say: if player.UserId ~= game.CreatorId then. But this would only work in a real server. Not studio. namespace25 594 — 4y
1
That worked, thanks! Phoenix_Ravin 19 — 4y
1
^^ I don't have 25 reputation yet, so take my imaginary upvote. Phoenix_Ravin 19 — 4y
0
Hope the upvotes help namespace25 594 — 4y
Ad

Answer this question