Kick command in a gui

So I don’t really know how to explain it but I am trying to get what’s inside of the TextBox so the player name how would I get that in a script.
image

That would be

Textbox.Text

You can test it out by doing

print(Textbox.Text)

Hope it helps! If you have any questions just reply. :+1:

Wait is it a textbutton or textbox i need for it to be able to execute or should I make an external enter button.

The Textbox should be for the admin to enter a username to kick. The text button should be the kick button.

Okay thanks I kinda get it now.

No problem! If you need any more help just ask me. :slight_smile:

Use RemoteEvents to communicate with the server:

--client, LocalScript
local Remote = game.ReplicatedStorage.KickRemote --a RemoteEvent named "KickRemote" 
local KickButton = script.Parent 
local TextBox = KickButton.Parent.Textbox 

KickButton.Activated:Connect(function()
	Remote:FireServer(TextBox.Text)
end)
--server, Script
local Players = game:GetService("Players")

local Remote = game.ReplicatedStorage.KickRemote --a RemoteEvent named "KickRemote" 

local admins = {admin1userID, admin2userID, etc.}

Remote.OnServerEvent:Connect(function(player1, targetUsername)
	if not table.find(admins, player1.UserId) then return end
	local player2 = Players:FindFirstChild(targetUsername)
	if not player2 then return end 
	player2:Kick("Kicked by UI") --if a message isn't provided, the default UI will be shown
end)
3 Likes

Well I am trying that and nothing is working but thanks.

Edit: Nevermind got it working.