Hello! So I wanted to add a feature where if a player adds a name into a TextBox, and the text in the TextBox is a player in the lobby, and if the player clicks a button, it will click the player whose name is in the TextBox. However, it doesn’t work and the Developer Consle says nothing.
For security reasons, a ServerScript should be used. As for the current code, I believe the issue is the PlayerAdded function, since it ends at line 9, meaning that anything inside of it will not be ran.
You should use a remote event In order to kick the player, try this:
LocalScript:
local event = script.Parent.RemoteEvent --or wherever It is :d
script.Parent.MouseButton1Click:Connect(function()
local PlayerNameInTextBox = script.Parent.Parent:WaitForChild(“TextBox”).Text
local Player = game.Players:FindFirstChild(PlayerNameInTextBox)
if Player then
event:FireServer(Player)
end
end)
(Server) Script:
local event = script.Parent.RemoteEvent
event.OnServerEvent:Connect(function(LocalPlayer, Player)
Player:Kick("Reason.")
end)
I’m kinda late, because I’m a slow typer on the phone
but still, hope I could help!