The title of the question explains the problem I'm having. I'm making a place for my class and only my classmates can join, I'm currently searching for solutions, if anyone can help me I'll be very happy!
Kick everyone else who is not allowed.
local PlayersWhoCanJoin = {} --Insert the players that can join. game.Players.PlayerAdded:connect(function(plr) local allowed = false for i, v in pairs(PlayersWhoCanJoin) do wait() if plr.Name == v then allowed = true break end end if not allowed then plr:Kick("You are not allowed to join this place.") end end)
Use playeradded, and check and see if their username is somebody in your class.
game.Players.PlayerAdded:connect(function(player) if player.Name ~= "FRIENDNAME" and player.Name ~= "FRIENDNAME" and player.Name ~= "FRIENDNAME" then player:Kick() end end)
Feel free to accept my answer if this helped you.
-- Dictionary table local admins = {['azarth'] = true} local players = game:GetService("Players") local function player_joined(player) if not admins[player.Name:lower()] then player:Kick() end end players.PlayerAdded:connect(function(plr) player_joined(plr) end) -- Grab everyone that PlayerAdded didn't connect to in case the script loaded after players joined. for i,v in pairs(players:GetPlayers()) do player_joined(v) end