Thanks! man where can I learn script like you?
It is ok at least i understand it now
If you’re starting out, it’s best to know what you really want to learn. Start with the basics. Youtube tutorials and then start using the Developer Wiki which is a really great resource for examples and somethint called API referencing which you can use to research a specific function or service and learn its use!
Good luck in your future projects! Scripting is a lot of fun.
Thanks dude I will see and try like that Thanks for the solution!
and I know scripting will be fun
No sir it is for my game not for a group game
See im testing my game but I need to make it public because in the output it says: “You must publish the game to access DataStore”. But im getting ready for a big update and i dont want the players to see the update. so I made another place but only for developers
You don’t even need a script for this, there’s native support.
See the permissions section in the following article:
https://developer.roblox.com/en-us/articles/game-settings
Release announcement is here:
https://devforum.roblox.com/t/introducing-unified-game-permissions/428956
Yeah but thats locking a game for developers only with game edit access.
This way I guess you can have the game public and still have the specific people you want join.
Game access permissions isn’t limited to Studio access. The first permission level, Play, allows users to play a game while it is closed without also granting them further access to your games. It has its respective benefits, such as in group games where you have a tester rank in a public join group: giving testers the “Play” permission will allow them to join the game while other members in the community rank cannot, voiding the need for a script at all.
Thank you thou i have only know it now
Im working with my dev friend so that we can edit the game
Note: This will kick anyone that isn’t at index 1 of the table. You should add a variable for finding in the table then deal with it after looping the table.
so is the script wrong and must be added? just tell me please
Here’s an edited version of the script provided by @b_oolean
local Whitelisted = {123,456,789} -- Use player ids as its more secure if a player was to change their username.
game.Players.PlayerAdded:Connect(function(player)
local isWhitelisted = false
for i,v in pairs(Whitelisted) do
if player.UserId == v then -- they're whitelisted!
print("Developer allowed to join!")
isWhitelisted = true
end
end
if not isWhitelisted then
player:Kick("Not whitelisted")
end
end)
(On mobile, indenting not great)
It’s completely unnecessary to loop through the table, you can just use table.find()
,
local Whitelisted = {123,456,789} -- Use player ids as its more secure if a player was to change their username.
game.Players.PlayerAdded:Connect(function(player)
if not table.find(Whitelisted,player.UserId) then
player:Kick("Not whitelisted")
end
end)
Good catch, I keep forgetting it exists.
No worries, there’s no major difference other than the script being shorter.
you can do like @COUNTYL1MITS but with a nil check…
local whitelist = {whatever}
game.Players.PlayerAdded:Connect(function(plr)
If table.find(whitelist, plr.Name) == nil then
plr:Kick("Developers Only")
end
end)
Though I would not recommend using usernames as they can be changed at anytime without notice while UserIds are permanent.
yea that’s true… 30dnzfdjrfdk