Kick Info Doesn't Pop Up

I’m making an administration panel for a game, and there’s a kick part on there. Everything is working fine except for the reason for the kick. I tried adding a table so that stuff will pop up when the player is kicked; however, it just pops up as “{}”

I’m rather new to some of this stuff, so I’m unsure what is wrong with my code. I am using a remote event with this too.

LOCAL SCRIPT - KICK HANDLER

local remoteevent = game:GetService("ReplicatedStorage"):FindFirstChild("Events"):WaitForChild("Kick")

script.Parent.MAIN.KICK.MouseButton1Click:Connect(function(player)
	local playername = script.Parent.PLAYERNAME.Text
	local reason = script.Parent.REASON.Text
	local kickinfo = {
		["Administrator"] = game.Players.LocalPlayer.Name,
		["UserID"] = playername.UserId,
		["Reason"] = reason,
		["Time"] = os.time(),
	}
	if playername == "" then
		script.Parent.PLAYERNAME.BorderColor3 = Color3.fromRGB(255, 0, 0)
		wait(1.5)
		script.Parent.PLAYERNAME.BorderColor3 = Color3.fromRGB(27, 42, 53)
	else
		if reason == "" then
			reason = "N/A"
			remoteevent:FireServer(playername, kickinfo)
			script.Parent.Visible = false
			wait(2.5)
			script.Parent.PLAYERNAME.Text = ""
			script.Parent.REASON.Text = ""
		else
			print("Kicking "..playername.." for: "..reason..".")
			remoteevent:FireServer(playername, kickinfo)
			script.Parent.Visible = false
			wait(2.5)
			script.Parent.PLAYERNAME.Text = ""
			script.Parent.REASON.Text = ""
		end
	end
end)

SERVER SCRIPT

local Administration = {"Comqts"}


local remoteevent = game:GetService("ReplicatedStorage"):FindFirstChild("Events"):WaitForChild("Kick")
remoteevent.OnServerEvent:Connect(function(player,playername,kickinfo)
	if table.find(Administration, player.Name) then
		for _,Players in pairs(game.Players:GetPlayers()) do
			if Players.Name == playername then
				Players:Kick(kickinfo)
			end
		end
	else
		player:Kick("You are not authorized to use this command.")
	end
end)

If anyone could help, please do. Thanks!

1 Like

image

1 Like

A table wont appear on the kick message try using a string.

Could you explain a little bit on how to do that?

Firstly, you can’t call UserId on text. UserId is exclusive to player objects. You can get the player’s name through player.Name, there is no need to pass that as a parameter.
As pointed out, you can’t send a table as the Kick Message parameter. It’ll most likely error. Speaking of errors, do you have any errors in the output? There certainly should be one for the UserId on the text, but what other ones are there?

A string is defined by speech marks: “” Put a string as a parameter in the Kick function like Kick(“You’ve been bad.”)

You can make use of the table.concat function. Do table.concat(kickinfo, " "). This’ll split all the elements in the table with a space.

1 Like

They have a table of parameters which they want to be outputted into the kick dialog (kickinfo)

I currently have no errors in the output for it.

With the whole table thing, I swear I’ve saw something on here before where someone made a timed ban system or whatever and use a table as a reason.

Gyazo
Gyazo

1 Like

You will also need to use parameters

1 Like

I know, but Kick function doesn’t accept tables.

1 Like

Yes, exactly. This is why you use table.concat and vel sim.

1 Like

Ok I was just explaining why that was appearing in as the message.

1 Like

They did this by using table.concat. They used the special newline character, \n, which puts the text on a new line.
You can achieve the same by doing this:

player:Kick(table.concat(kickinfo, "\n"))

LMK if this works or doesn’t work.

That didn’t work. Now it doesn’t really show anything except “You were kicked fromt his experience: You have been kicked from the game”
image

Output:

Server Kick Message:

local Administration = {"Comqts"}


local remoteevent = game:GetService("ReplicatedStorage"):FindFirstChild("Events"):WaitForChild("Kick")
remoteevent.OnServerEvent:Connect(function(player,playername,kickinfo)
	if table.find(Administration, player.Name) then
		for _,Players in pairs(game.Players:GetPlayers()) do
			if Players.Name == playername then
				Players:Kick(table.concat(kickinfo,"\n"))
			end
		end
	else
		player:Kick("You are not authorized to use this command.")
	end
end)

This is what I put, by the way.

table.concat doesn’t work with dictionaries

forgot this was a dictionary :\ no wonder it didn’t wrok

Do you have any other ideas, by chance?

Yes. You can remove the dictionary keys, and instead just have this:

local kickinfo = {
    "Administrator: "..game.Players.LocalPlayer.Name,
    "UserID: "..tostring(game.Players:FindFirstChild(playername).UserId),
    "Reason: "..reason,
    "Time: "..os.time()
}