Okay, I am making an admin script, but on commands, such as rejoin and reset it requires a players name, and I don't want them commands to have that. Only kick and kill should have it. i.e. ;kick mosski123
Here is my code;
local Admins = { ["19498972"] = true, ["1540993"] = true, ["46641586"] = true } local prefix = ';' local commandTable = {} function findPlayer(name) for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end function commandTable.reset(message, player) player.Character:BreakJoints() end function commandTable.rejoin(message, player) game:GetService("TeleportService"):Teleport(game.PlaceId, player) if player.Character ~= nil then player.Character:remove() end end function commandTable.kill(message, player) victim = findPlayer(message) if victim and victim.Character then victim.Character:BreakJoints() end end function commandTable.kick(message, player) victim = findPlayer(message) if victim and victim.Character then victim:Kick("[KICK]: "..player.Name.." has kicked you from the server.") end end game.Players.PlayerAdded:connect(function(player) if Admins[tostring(player.UserId)] then player.Chatted:Connect(function(message) local command, argument = message:match(prefix.."(.+) (.+)") if command and commandTable[command] then commandTable[command](argument, player) end end) end end)
I suggest you use String Manipulation. To be specific: string.sub(). What this done is it takes out a specificied section out of a string. This means that you can assign the player as a seperate variable by using string.sub().
For example, if you wanted to kill a player, do:
local target = string.sub(message, 6)
The above will take out anything said after ;kick or ;kill.