I'm trying to make admin commands by linking modules to different sections.
So far, my script connects to the correct command module, which then brackets off to the parser which determines what player/group it's going to perform the command on, it then brackets off to the player/group module which then tells the script how it's going to run; Eg. Group: All - would select all players - It would then return that module back to the original kill module and kill everyone...
However, the modules aren't working in the correct way and is only causing the speaker to die instead of the whole server.. Any ideas?
Kill Command Module
return function(Speaker, plrName ) if plrName then local ThePlayer = require(script.Parent.Parent.Settings.Groups.Parser) local selectedPlayer = ThePlayer.Obj(plrName) if typeof(selectedPlayer) == "table" then for _, v in pairs(selectedPlayer) do v:BreakJoints() end else selectedPlayer:BreakJoints() end print( string.format("Testing command on : '%s'!", plrName) ) else warn( string.format("command '%s' got invalid arguments. Skipping..", script.Name ) ) end end
Parser Module
local module = {} function module.Obj(plrName) if plrName:lower() == "!all" then local AllPlayers = require(script.Parent.AllPlayers) return AllPlayers.Obj(plrName) end end return module
AllPlayers Module
local module = {} function module.Obj(plrName) local plrs = game:GetService("Players") for i, player in pairs(plrs:GetPlayers()) do plrName = player.Character return plrName end end return module
Thank you in-advance!
AllPlayers is only returning one player. the return is breaking the loop.
The AllPlayers module:
local module = {} function module.Obj(plrName) local characters = {} local plrs = game:GetService("Players") for i, player in pairs(plrs:GetPlayers()) do table.insert(characters, player.Character) end return characters end return module
have a nice day. I don't know what tuples have to do with this.