What is wrong with my kick script

So I have decided to redo an admin panel but I don’t know how to get a username inserted into a text box and then have an event fired that kicks that user.

Current script:
Local

local MainUi = script.Parent.Parent.Parent
local inputs = MainUi.Inputs

script.Parent.MouseButton1Click:Connect(function()
	local user = inputs.Username.Text
	local reason = inputs.Reason.Text
	game.ReplicatedStorage.Kick:FireServer(user, reason)
end)

Server

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local KickEvent = ReplicatedStorage:WaitForChild("Kick")

KickEvent.OnServerEvent:Connect(function(user, reason)
	local PlayerKick = game.Players:FindFirstChild(user)
	PlayerKick:Kick(reason)
end)

I know I’m missing a few things but I don’t know what exactly it is so I was hoping you guys can help me.

1 Like

I see you’re passing user and reason to the remote, but also the server will automatically pass the player that triggered the event as the first argument. So it should be function(player, user, reason).

1 Like

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)

local KickEvent = ReplicatedStorage:WaitForChild(“Kick”)

KickEvent.OnServerEvent:Connect(function(player,user, reason) but player here
local PlayerKick = game.Players:FindFirstChild(user)
PlayerKick:Kick(reason)
end)