Solved! Thanks for the help everyone.
Where exactly does it say, the argument1 missing or nil?
Secondly, I suggest scripting it like this.
local SS = game:GetService("ServerScriptService")
local perms = require(SS:WaitForChild("MainModule"))
local authorized = {"achdef"}
local prefix = "!"
game.Players.PlayerAdded:Connect(function(plr)
for i, authorized in pairs(authorized) do
if plr.Name == authorized then
plr.Chatted:Connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."fail" then
if msg[2] then
local target = game:GetService("Players"):FindFirstChild(msg[2].Name)
perms:PlayerKick(target,"failed.")
end
end
end)
end
end
end)
Itâs said it at 'perms:PlayerKick(target,âfailedâ.).
Sorry for the late response!
Alright, let me see.
Could I request the playermoudle, and whatâs in it? As that could be the issue.
Try this, remove the â.â in âfailedâ as that could error the script.
perms:PlayerKick(target,"failed")
Nope, itâs still not working, and the error is the same.
Could I request the kick Module, and whatâs in it? As that could be the issue, and could I get a picture of the error too, sorry for the amount of requests haha.
Yes, of course! Give me one second.
Hi! Try with this, it worked fine for me.
local SS = game:GetService("ServerScriptService")
local perms = require(SS:WaitForChild("MainModule"))
local authorized = {"achdef"}
local prefix = "!"
game.Players.PlayerAdded:Connect(function(plr)
for _, authorized in pairs(authorized) do
if plr.Name == authorized then
plr.Chatted:Connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."fail" and msg[2] then
local target = game:GetService("Players"):FindFirstChild(msg[2])
perms:PlayerKick(target, "failed.")
end
end)
end
end
end)
Trying to get the .Name of a string (message) cause an error.
Edit: Replied wrong person.
Argument 1, or nil missing
Meaning that you will require a reason for it, a work-around for it would be this.
local SS = game:GetService("ServerScriptService")
local perms = require(SS:WaitForChild("MainModule"))
local authorized = {"achdef"}
local prefix = "!"
local Reason = "hi lol fattie u failed"
game.Players.PlayerAdded:Connect(function(plr)
for _, authorized in pairs(authorized) do
if plr.Name == authorized then
plr.Chatted:Connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."fail" and msg[2] then
local target = game:GetService("Players"):FindFirstChild(msg[2])
perms:PlayerKick(target, Reason)
end
end)
end
end
end)
If that doesnât work it means the target that you are getting is nil. (Meaning no value)
Didnât work⌠This is confusing.
local SS = game:GetService("ServerScriptService")
local perms = require(SS:WaitForChild("MainModule"))
local authorized = {"achdef"}
local prefix = "!"
local Reason = "hi lol fattie u failed"
game.Players.PlayerAdded:Connect(function(plr)
for _, authorized in pairs(authorized) do
if plr.Name == authorized then
plr.Chatted:Connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."fail" and msg[2] then
local target = game.Players:FindFirstChild(msg[2])
perms:PlayerKick(target, Reason)
end
end)
end
end
end)
This should work.
May you send the current code that you have putted?
Oh wait. Itâs because there is not â.Nameâ probably. Let me check if that the case.
No justly, donât put it. Attemping to get the .Name of a String will cause an error.
local SS = game:GetService("ServerScriptService")
local perms = require(SS:WaitForChild("MainModule"))
local authorized = {"achdef"}
local prefix = "!"
local Reason = "failed cuz ur fat"
game.Players.PlayerAdded:Connect(function(plr)
for _, authorized in pairs(authorized) do
if plr.Name == authorized then
plr.Chatted:Connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."fail" and msg[2] then
local target = game:GetService("Players"):FindFirstChild(msg[2])
perms:PlayerKick(target, Reason or "failed")
end
end)
end
end
end)
Try this:
--// Script
local SS = game:GetService("ServerScriptService")
local perms = require(SS:WaitForChild("MainModule"))
local authorized = {"achdef"}
local prefix = "!"
local Reason = "Failed."
game.Players.PlayerAdded:Connect(function(plr)
for _, authorized in pairs(authorized) do
if plr.Name == authorized then
plr.Chatted:Connect(function(message)
local msg = message:split(" ")
if msg[1] == prefix.."fail" and msg[2] then
perms:PlayerKick(msg[2], Reason)
end
end)
end
end
end)
--// ModuleScript
function banService:PlayerKick(target, reason)
-- Check if player exists in 'Players' and if there's a reason
local player = game:GetService("Players"):FindFirstChild(target)
if player and reason then
player:kick(reason)
print("Successfully kicked", player.Name)
end
end
FindFirstChild returns false if the instance is not existing, so if you put a bad name it could send as arguments: perms:PlayerKick(false, Reason)
Okay, I fixed it. Thanks for the help yâall!
I see this thread has already been solved, but I was writing this so Iâll still leave it here. I debugged your problem just out of curiosity instead of just rewriting the whole thing.
By default this module writes this call as KickPlayer, not PlayerKick (maybe you changed it, in which case this isnât a problem).
Additionally, that call will never work by default within the module because it tries to index nonexistant variables. This is not your fault.