Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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)
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. GetGlobals 343 — 6y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

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)
Ad

Answer this question