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

how to fix my script to only let some pepole have acces to my game?

Asked by
hokyboy 270 Moderation Voter
5 years ago
if game.Players.PlayerAdded:Connect(fucntion()  
if game.Players.LocalPlayer.Name == ("hokyboy,Kampatala") then
    script.Parent.Parent.Parent:Destroy()

end

so this is what i tried i first tried it with a loop(yes i was bening stupid) now i dont know how to fix this and is there a way to kick a player using this metod and then let the kick say Error:You dont have acces to this game?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

yes; and here is how you can do it

local allowed = {
    "Arsubia12",
    "bleh"
}


game.Players.PlayerAdded:Connect(function(player)
    for _, plr in pairs(allowed) do
        if player.Name:lower() == plr:lower() then
            return 0 ;
        end
    end

    player:Kick("You dont have acces to this game?")
end)

in the variable allowed, put in the names of the people that are allowed to join separated with commas

Ad

Answer this question