Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to call method on object of type: `Players` with incorrect arguments?

I'm trying to make a kick GUI, but this keeps popping up

16:19:38.321 - Trying to call method on object of type: Players with incorrect arguments. 16:19:38.322 - Stack Begin 16:19:38.322 - Script 'ServerScriptService.ScriptingEvents.KickPlayerReason', Line 5 16:19:38.323 - Stack End

I'll put both scripts if needed:

--SERVER SCRIPT--
local RS = game:GetService("ReplicatedStorage")
local twigger = RS.OwnerRemotes:WaitForChild("KickFrame")

twigger.OnServerEvent:Connect(function(plr, plrname, reason)
	game.Players(plrname):Kick(plrname.Value.. "|".. (reason.Value)) -- The problem/error
	end)
--LOCAL SCRIPT--
local RS = game:GetService("ReplicatedStorage")
local remotea = RS.OwnerRemotes:WaitForChild("KickFrame")

script.Parent.CB.MouseButton1Click:Connect(function()

local yeeter = script.Parent.reasonBox.reasonValue
local yeet = script.Parent.userBox.userValue

remotea:FireServer(yeet, yeeter)
end)

1 comment

0

Instead of game.Players(plrname) you should do game.Players[plrname] because using the () on the object makes the code assume you are trying to use the Players object as a function.

1 answer

✓ Accepted answer

First of all, this remote is easily exploitable.

and, you're indexing the player wrongly.

--part of server code

game.Players[plrname]:Kick(plrname.. '|' .. reason)

--part of client code

remotea:FireServer(yeet.Value, yeeter.Value)

This discussion is preserved as it was. New answers, comments, and votes are closed.