works fine in studio and in normal player (as far as printing(user can't cheat bla bla) however it's not detecting that my name is on the table, can somebody please tell me what I did wrong?
-- // FileName: AdminCommands.lua
-- // Written by: NextYearStudios
-- // Description: Various admin commands
local Admin = {'player1','nextyearstudios'}
local Chat = game:GetService("Chat")
local ReplicatedModules = Chat:WaitForChild("ClientChatModules")
local ChatConstants = require(ReplicatedModules:WaitForChild("ChatConstants"))
local function test(speakerName, messageObj, channelName)
local message = messageObj.Message
local leaderstats = game.Players[speakerName]:WaitForChild("leaderstats")
if message and string.sub(message, 1, 7):lower() == ":cheat " then
if string.sub(message,8,13):lower() == "money " then
print(string.sub(message, 8, 12))
leaderstats.Money.Value = leaderstats.Money.Value + string.sub(message,14)
elseif string.sub(message,8,18):lower() == "experience " then
print(string.sub(message, 8, 18))
leaderstats.EXP.Value = leaderstats.EXP.Value + string.sub(message,19)
elseif string.sub(message,8,13):lower() == "level " then
print(string.sub(message, 8,12))
leaderstats.Level.Value = leaderstats.Level.Value + string.sub(message,14)
else
print('command not found')
end
end
end
local function Run(ChatService)
local function AdminCommandFilterFunction(speakerName, messageObj, channelName)
local message = messageObj.Message
if message and string.sub(message, 1, 7):lower() == ":cheat " then
for _,a in ipairs(Admin) do
if string.lower(speakerName) == a then
print('player is admin, cheating is allowed')
test(speakerName, messageObj, channelName)
else
print('not an admin, cant cheat')
return
end
end
end
end
ChatService:RegisterFilterMessageFunction("Admin_command", AdminCommandFilterFunction)
end
return Run

1 comment
Never use the Studio Test unless you're testing something really quickly. Use the Server Test that studio provides. It will give you errors and is a simulated-live-game experience. To do so, go to the Testing tab, then click 'Start', as opposed to 'Play'