I don't really get what you're trying to make..? TextButton isn't customizable unless if it was being controlled by a script. But I'm assuming this is what you're looking for.
Insert a RemoteEvent in ReplicatedStorage, then insert this script (localscript) in the button.
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("KickEvent")
script.Parent.MouseButton1Click:Connect(function()
Event:FireServer(script.Parent.Text)
end)
Then insert a server script in serverscriptservice
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("KickEvent")
Event.OnServerEvent:Connect(function(plr, target)
local plrToKick = Players:FindFirstChild(target)
if plrToKick then
plrToKick:Kick("\n You have been kicked by a moderator")
end
end)
Unless if you want to kick yourself then...
Client
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer:Kick()
end)
8 comments
is it a localscript?
yes
you can't kick through localscripts, you got to use remote events to do that
so an fire server i should do it though?
You can kick on LocalScript - but you can only kick yourself though. However, that question is currently irrelevant; since we're talking about index nil, not attempt to kick other client
Correct me if I'm wrong, but you're using a TextBox, correct?
Button
Make a local script which fires a remote event when the button is clicked and then make a script when detects when the remote event has been fired and then kick the player