So I have these scripts which are suppose to give me and any other user I set to admin(I know the pm command in chat cmds wont work! Please don't mention it).
Server script Admin in workspace:
_G.DSService = game:GetService('DataStoreService'):GetDataStore('nope, not going to know my data store')
defaultadmins = {98016926}
local GetSaved = _G.DSService:GetAsync("admins")
if not GetSaved then
_G.DSService:SetAsync("admins", _G.defaultadmins)
end
local getda = Instance.new("RemoteFunction") -- creates the event object
getda.Parent = game.Workspace -- puts the event into the Workspace
getda.Name = "GetDefaultAdmins" -- giving a name to the event so we can fire it specifically elsewhere
function getda.OnServerInvoke() -- define the function that will be called when the event is fired
return defaultadmins
end
local geta = Instance.new("RemoteFunction") -- creates the event object
geta.Parent = game.Workspace -- puts the event into the Workspace
geta.Name = "GetAsync" -- giving a name to the event so we can fire it specifically elsewhere
function geta.OnServerInvoke(player, wtg) -- define the function that will be called when the event is fired
return _G.DSService:GetAsync(wtg)
end
local seta = Instance.new("RemoteFunction") -- creates the event object
seta.Parent = game.Workspace -- puts the event into the Workspace
seta.Name = "SetAsync" -- giving a name to the event so we can fire it specifically elsewhere
function seta.OnServerInvoke(player, wtg, object) -- define the function that will be called when the event is fired
return _G.DSService:SetAsync(wtg, object)
end
I have gamepasses which is a server script in workspace.
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(character)
repeat
wait()
until _G.DSService:GetAsync("admins")
local admins = _G.DSService:GetAsync("admins")
if game:GetService("GamePassService"):PlayerHasPass(p, 492262492) then --speed
workspace[p.Name]:WaitForChild("Humanoid").WalkSpeed = 100
end
if game:GetService("GamePassService"):PlayerHasPass(p, 496545632) then --vip
game.ReplicatedStorage.Spatula:Clone().Parent = p.Backpack
end
if has_value(admins, p.UserId) then
game.ReplicatedStorage.Spatula:Clone().Parent = p.Backpack
workspace[p.Name]:WaitForChild("Humanoid").WalkSpeed = 100
end
end)
end)
function has_value(tab, val)
for index, value in ipairs (tab) do
if value == val then
return true
end
end
return false
end
And a localscript chat cmds in starterplayerscripts.
repeat
wait()
until workspace.GetAsync:InvokeServer("admins")
defaultadmins = workspace.GetDefaultAdmins:InvokeServer()
local player = game.Players.LocalPlayer
GetSaved = workspace.GetAsync:InvokeServer("admins")
function has_value(tab, val)
for index, value in ipairs (tab) do
if value == val then
return true
end
end
return false
end
if has_value(GetSaved, player.UserId) then
if has_value(defaultadmins, player.UserId) then
player.Team = game.Teams.Owner
else
player.Team = game.Teams.Admin
end
end
player.Chatted:connect(function(msg)
GetSaved = workspace.GetAsync:InvokeServer("admins")
if has_value(GetSaved, player.UserId) then --admin commands
if has_value(defaultadmins, player.UserId) then --main owner commands
if msg == ":reseta" then
print("Admins RESET!")
workspace.SetAsync:InvokeServer("admins", defaultadmins)
end
if split(msg, "%s")[1] == ":adda" then
if split(msg, "%s")[2] then
print("Admin added!")
local tempt = GetSaved
if not has_value(tempt, split(msg, "%s")[2]) then
table.insert(tempt, split(msg, "%s")[2])
end
workspace.SetAsync:InvokeServer("admins", tempt)
end
end
if split(msg, "%s")[1] == ":removea" then
if split(msg, "%s")[2] then
print("Admin removed!")
local tempt = GetSaved
if has_value(tempt, split(msg, "%s")[2]) then
removekey(tempt, split(msg, "%s")[2])
end
workspace.SetAsync:InvokeServer("admins", tempt)
end
end
end
if msg == ":lista" then
print("Admins:")
for _,object in pairs(GetSaved) do
print(object)
end
end
if split(msg, "%s")[1] == ":givem" then
if split(msg, "%s")[2] and split(msg, "%s")[3] then
if tonumber(split(msg, "%s")[3]) then
if game.Players:FindFirstChild(split(msg, "%s")[2]) ~= nil then
local p2 = game.Players:FindFirstChild(split(msg, "%s")[2])
p2.leaderstats.Money.Value = p2.leaderstats.Money.Value + split(msg, "%s")[3]
end
end
end
end
if split(msg, "%s")[1] == ":takem" then
if split(msg, "%s")[2] and split(msg, "%s")[3] then
if game.Players:FindFirstChild(split(msg, "%s")[2]) ~= nil then
if tonumber(split(msg, "%s")[3]) then
local p2 = game.Players:FindFirstChild(split(msg, "%s")[2])
if p2.leaderstats.Money.Value >= tonumber(split(msg, "%s")[3]) then
p2.leaderstats.Money.Value = p2.leaderstats.Money.Value - split(msg, "%s")[3]
end
end
end
end
end
if split(msg, "%s")[1] == ":reset" then
if split(msg, "%s")[2] then
if workspace:FindFirstChild(split(msg, "%s")[2]) ~= nil then
workspace:FindFirstChild(split(msg, "%s")[2]).Humanoid.Health = 0
end
end
end
if split(msg, "%s")[1] == ":pm" then
if split(msg, "%s")[2] and split(msg, "%s")[3] then
if game.Players:FindFirstChild(split(msg, "%s")[2]) ~= nil then
local pm = game.ReplicatedStorage.msgs:Clone()
pm.msg.Text = split(msg, "%s")[3]
pm.profpic.TextLabel.Text = player.Name
pm.profpic.Image = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username="..player.Name
pm.Parent = game.Players:FindFirstChild(split(msg, "%s")[2]).PlayerGui.popups
end
end
end
end
end)
function removekey(tab, key)
for _,object in pairs(tab) do
if object == key then
table.remove(tab,_)
break
end
end
return tab
end
function split(pString, pPattern)
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end
Basically what happens is if my user id is in defaultadmins, I am set as owner, and if its not, I'm set as admin, as I am still in the datastore. But whenever I add someone else to the datastore, it just acts as if they are not there. I am able to make sure they are in the datastore with :lista, and because of that, I need a lead or code to fix it. Thanks!

4 comments
Thanks! But will that solve my error? I currently have no one else online to help me test.
Oops, just realized that was a mistake, but that wont fix my problem!
Well what is the output?
I get no error or anything. But no other players have anything in gamepasses or chat cmds.