Heyo! I’m trying to figure out how to get the player who executed a command. My script so far:
local Plugin = function(...)
local Data = {...}
-- Included Functions and Info --
local remoteEvent = Data[1][1]
local remoteFunction = Data[1][2]
local returnPermissions = Data[1][3]
local Commands = Data[1][4]
local Prefix = Data[1][5]
local actionPrefix = Data[1][6]
local returnPlayers = Data[1][7]
local cleanData = Data[1][8] -- cleanData(Sender,Receiver,Data)
-- Practical example, for a gui specifically for a player, from another player
-- cleanData(Sender,Receiver,"hi") -- You need receiver because it's being sent to everyone
-- Or for a broadcast (something everyone sees, from one person, to nobody specific)
-- cleanData(Sender,nil,"hi") -- Receiver is nil because it is a broadcast
-- Plugin Configuration --
local pluginName = 'warn'
local pluginPrefix = Prefix
local pluginLevel = 2
local pluginUsage = "reason" -- leave blank if the command has no arguments
local pluginDescription = "Warn users for violating rules!"
local httpService = game:GetService('HttpService')
local url = "no stealing hehe"
-- Example Plugin Function --
local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
local Player = Args[1]
local Victims = returnPlayers(Player,Args[3],Args[2]) if not Victims then return end -- this will ignore the command if you're not include the player(s).
local Reason = Args[4]
local combinedArgs = ""
for a,b in pairs(Args) do
if a > 3 then
combinedArgs = combinedArgs..b..' '
end
end
if combinedArgs ~= "" then
Reason = combinedArgs
end
for a,b in next,Victims do
remoteEvent:FireClient(b, 'PM', 'System', 'You have been warned by: @' .. Player.Name .. '.\nThis is your ' .. game.Players[b.Name].Warns.Value +1 .. ' warning!\n' .. 'You were warned for: ' ..Reason)
print(game.Players[b.Name].Warns.Value)
game.Players[b.Name].Warns.Value = game.Players[b.Name].Warns.Value + 1
print(game.Players[b.Name].Warns.Value)
local whData = {
["embeds"] = {{
["title"] = "The Warns Command Was Used!",
["description"] = "**Username**: "..Data[1].Name, -- FOCUS HERE!!!!
["color"] = tonumber(16711680),
["fields"] = {
{
["name"] = "Warned Player:",
["value"] = Player.Name.." | "..Args[1],
["inline"] = false,
},
{
["name"] = "Warning Reason:",
["value"] = Reason,
["inline"] = false,
}
},
}}
}
local finalData = httpService:JSONEncode(whData)
httpService:PostAsync(url, finalData)
if game.Players[b.Name].Warns.Value >= 3 then
game.Players[b.Name]:Kick("\n You have reached the maxium amount of warnings and have been automatically disconnected from the server!")
end
end
end
-- Return Everything to the MainModule --
local descToReturn
if pluginUsage ~= "" then
descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
else
descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
end
return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}
end
return Plugin