So I have tried using the server.RunCommand() function in a custom command module but whatever I do I just get “attempt to call a nil value” error. I tried looking at the DevForum but it seemed like it worked for others unless I’m doing something wrong but I’m not sure what to do at this point.
--[[
SERVER PLUGINS' NAMES MUST START WITH "Server: "
CLIENT PLUGINS' NAMES MUST START WITH "Client: "
Plugins have full access to the server/client tables and most variables.
You can use the MakePluginEvent to use the script instead of setting up an event.
PlayerChatted will get chats from the custom chat and nil players.
PlayerJoined will fire after the player finishes initial loading
CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
service.HookEvent('PlayerChatted',function(msg,plr)
print(msg..' from '..plr.Name..' Example Plugin')
end)
service.HookEvent('PlayerJoined',function(p)
print(p.Name..' Joined! Example Plugin')
end)
service.HookEvent('CharacterAdded',function(plr)
server.RunCommand('name',plr.Name,'BobTest Example Plugin')
end)
--]]
server = nil -- Mutes warnings about unknown globals
service = nil
return function()
server.Commands.RunCommandTestCommand = {
Prefix = server.Settings.Prefix; -- Prefix to use for command
Commands = {"runcommandtest", "test"}; -- Commands
Args = {"player"}; -- Command arguments
Description = "test the RunCommand function"; -- Command Description
Hidden = false; -- Is it hidden from the command list?
Fun = false; -- Is it fun?
AdminLevel = "Moderators"; -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
Function = function(plr,args) -- Function to run for command
for _, player in pairs(service.GetPlayers(plr,args[1])) do
server.RunCommand('name',player.Name,'test')
end
end
}
end