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

how can i get users from a module script and make it print if the user is the correct user?

Asked by 4 years ago

i want to make a script that does print when a player joins and has the same name/userid as the one in the module script but i dont know how to do that, here's the script:

01local Whitelist = require(script.Parent.Whitelist)
02local player = game:GetService("Players")
03 
04player.PlayerAdded:Connect(function(plr)
05    if plr.Name == Whitelist.whitelist.Users then
06        print('Whitelisted')
07    else
08        print('Not Whitelisted')
09    end
10end)

and here's the module script:

1local whitelist = {}
2 
3whitelist.Users = {"mahid786", "GameTime_Studio", "diegodamaw", "amirgun2", "Bloxy_Cone"}
4 
5return whitelist

can someone please help me?

1 answer

Log in to vote
1
Answered by
VVoretex 146
4 years ago

Ok so, a ModuleScript is not required, you can put the usernames in a normal script inside ServerScriptService(SSS). Or alternatively use this script:

1local admins = {"player1","player2"}
2 
3game.Players.PlayerAdded:Connect(function(player)
4    for i = 1, #admins do
5            if admins[i] == player.Name then
6--whatever you want
0
thanks this works! mahid786 41 — 4y
0
welcome! VVoretex 146 — 4y
Ad

Answer this question