I have an admin GUI stored in server storage, to keep it safe from exploiters. When a player joins, my system figures out the roles, then clones it into my gui. In that admin GUI, there is a simple kick script. (The event is in the GUI)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plrName, Reason, returnPlr)
plrName = tostring(plrName)
Reason = tostring(Reason)
local Success, Error = pcall(function()
local plrID = game.Players:GetUserIdFromNameAsync(plrName)
local plr = game.Players:GetPlayerByUserId(plrID)
if plr then
print(plr.Name)
plr:Kick(Reason)
script.Parent.Callback:FireClient(returnPlr, "Successfully kicked "..plrName)
else
script.Parent.Callback:FireClient(returnPlr, "Invalid")
end
end)
if not Success then
script.Parent.Callback:FireClient(returnPlr, "Error | Devs Check Console")
error(Error)
end
end)
~~~~~~~~~~~~~~~~
What the event returns is the player's name and reason. These all return the correct things. But no matter what I do, I cannot kick another player. It kicks me for an unspecified reason.
I came with no errors, it returns the plrname and reason correctly.
What am I doing wrong?
Thanks in advance
Signed - Cheslin23t

3 comments
The cloning is in server script service, the script is ran from a admin's player gui. I bring the player name and reason from the local script, then the server will kick them.
Are you using free models / plugins, if so, either delete or disable one of them, or you may set the wrong code on remote event or function.
lmao no.