You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? For it to show the reason when they get kicked.
What is the issue? Doesn’t show the reason
What solutions have you tried so far? No I did not find anything I tried messing with it but nothing changed.
local Players = game:GetService("Players")
local Remote = game.ReplicatedStorage.KICK
local admins = {528285072}
Remote.OnServerEvent:Connect(function(player1, targetUsername, reason)
local reason = game.StarterGui.AdminPanel.KICKCMD.Reason == reason
if not table.find(admins, player1.UserId) then return end
local player2 = Players:FindFirstChild(targetUsername)
if not player2 then return end
player2:Kick("Kicked for", reason)
end)
local Remote = game.ReplicatedStorage.KICK
local admins = {528285072}
Remote.OnServerEvent:Connect(function(player1, targetUsername, reason)
local reason = game.StarterGui.AdminPanel.KICKCMD.Reason
if not table.find(admins, player1.UserId) then return end
local player2 = Players:FindFirstChild(targetUsername)
if not player2 then return end
player2:Kick("Kicked for".. reason)
end)```
Issue 1:game.StarterGui.AdminPanel.KICKCMD.Reason == reason is a boolean because you are comparing reason with another value (if the kick reason is being supplied by the event call, what’s the point of this line?).
Issue 2: You’re supplying the reason as an argument to the Player:Kick() method instead of concatenating it to the string "Kicked for". The correct way to do this would be "Kicked for" .. reason.
local Players = game:GetService("Players")
local Remote = game.ReplicatedStorage.KICK
local admins = {528285072}
Remote.OnServerEvent:Connect(function(player1, targetUsername, reason)
local reason = player1.PlayerGui.AdminPanel.KICKCMD.Reason.Text
if not table.find(admins, player1.UserId) then return end
local player2 = Players:FindFirstChild(targetUsername)
if not player2 then return end
player2:Kick("Kicked for: ".. reason)
end)
TextBoxes don’t replicate to the server when edited by a player, so you have to pass it as a remote argument.
Something like this:
--Client
Remote:FireServer("username", "reason")
--Server
Remote.OnServerEvent:Connect(function(player1, targetUsername, reason)
if not table.find(admins, player1.UserId) then return end
local player2 = Players:FindFirstChild(targetUsername)
if not player2 then return end
player2:Kick("Kicked for", reason)
end)
local Players = game:GetService(“Players”)
local Remote = game.ReplicatedStorage.KICK
local admins = {528285072}
Remote.OnServerEvent:Connect(function(player1, targetUsername, reason)
local reason = game.StarterGui.AdminPanel.KICKCMD.Reason == reason
if not table.find(admins, player1.UserId) then return end
local player2 = Players:FindFirstChild(targetUsername)
if not player2 then return end
player2:Kick("Kicked for"..reason)
end)
Doing :kick(“Reason For:”, Reason) will not work cuz you can only add a message on the kick as stated in the doc.
What @LifeDigger says is correct. You need to concatenate (combine) your reason with your string like this:
Player2:Kick(“Kicked for”..reason)
Also, as @LifeDigger said, you should kick them via the server. Kicking from clients is very easily exploitable and hackers can kick whomever they want.
No joke just kick from the server. From reviewing ur code I really don’t think there is a reason you have to kick them from the client side.
I really think everything that your wanting to do can easily be done via the server and no need to do any request to the client side unless I am incorrectly understanding what your looking for.