What is script.Parent.Parent.Title? If it's a TextBox then the issue would be that when you're typing text into a textbox, you're typing it from your client and therefore the server can't read the text you've just inputted.
To fix this, I'd suggest using a RemoteEvent and passing the Text from the client to the server, and to also check if the player that fired the RemoteEvent is an admin to avoid exploiters abusing this.
Local Script
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
local plrname = script.Parent.Parent.Title.Text
RemoteEvent:FireServer(plrname)
end)
Server Script
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
RemoteEvent.OnServerEvent:Connect(function(PlayerFired, PlayerToKick)
if PlayerToKick then
if game.Players:FindFirstChild(PlayerToKick) then
game.Players[PlayerToKick]:Kick("You have been kicked")
end
end
end)
1 comment
If its a script trying to get a mousebutton click it probably wont work try putting this in a local script and then setting a remote event to fire a message to the server to kick the player, hopefully this helps!