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:

local Whitelist = require(script.Parent.Whitelist)
local player = game:GetService("Players")

player.PlayerAdded:Connect(function(plr)
    if plr.Name == Whitelist.whitelist.Users then
        print('Whitelisted')
    else
        print('Not Whitelisted')
    end
end)

and here's the module script:

local whitelist = {}

whitelist.Users = {"mahid786", "GameTime_Studio", "diegodamaw", "amirgun2", "Bloxy_Cone"}

return 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:

local admins = {"player1","player2"}

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

Answer this question