I was creating a admin script and I kept having a problem were it wouldn't detect a player being added. I've sent prints through and it works until it checks for the player to be added which is confusing. This has worked for me before but not now.
local Admin = require(script.DollorsAdmin)
script.DollorsAdmin.Parent = game.ReplicatedStorage
local Settings = {
Prefix = '?', --The key you want to use before a command EX: ?kill [user]
OwnerOnly = false, --If you want only the owner to use commands
}
Admin.GetPrefix(Settings.Prefix)
if Admin.Loaded == true then
print('Admin Loaded!')
else
warn('Admin Could not load. Please rejoin the server.')
end
local GameOwnerName
local PlaceId = game.PlaceId
local PlaceInfo = game:GetService("MarketplaceService"):GetProductInfo(PlaceId)
if PlaceInfo.Creator.CreatorType == "Group" then
GameOwnerName = game:GetService("GroupService"):GetGroupInfoAsync(PlaceInfo.Creator.CreatorTargetId).Owner.Name
elseif PlaceInfo.Creator.CreatorType == "User" then
GameOwnerName = PlaceInfo.Creator.Name
end
local AdminIDs = {} --Must be user ID's. Game owner's ID is automatically put here
local OwnerID = game.Players:GetUserIdFromNameAsync(GameOwnerName)
table.insert(AdminIDs, #AdminIDs + 1, OwnerID)
game.Players.PlayerAdded:Connect(function(plr)
print(plr.Name)
for i, v in pairs(AdminIDs) do
if plr.UserId == v then
plr.Chatted:Connect(function(msg)
if msg:sub(1, 1) == Settings.Prefix then
Admin.SendCommand(msg)
end
end)
end
end
end)
I don't understand why at the end at line 33 I get no error but it never printed the players name on add...

1 comment
put a wait() before the function