Admin script(Enter player's name and immediately kills the player, but doesn't works)

Hello, as you see I’m trying to make an admin script.
So, basically when you enter a player’s name, then it finds the player and immediately kills him.
I’ve used a textbox specifically for it.
Sadly no solution.
You can check at the bottom of the page how much I’ve worked.

image


[local script]
local Box = script.Parent

local ok = game.Players:FindFirstChildWhichIsA(“Player”)

Box.Changed:Connect(function()

game.ReplicatedStorage.RemoteEvent:FireServer()

end)

script{}

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
local plrGui = plr:WaitForChild(“PlayerGui”)
local ScreenGui = plrGui:WaitForChild(“ScreenGui”)
local Box = ScreenGui.TextBox
Box.Changed:Connect(function()
if Box.Text == plr.Name then
plr:Destroy()
end
end)
end)

I have looked everywhere, even youtube devforums, etc.

I have tried everything thinking looking through forums and trying to find a solution.
It took a lot of time.
If anyone could help me with this script then I will be saved from this headache.

All I’m asking is a solution, that’s it and thank you!

Your scripts are very messed up. Why are you firing the event every time someone changes the text of the box? Why are you listening to the changed event on the server script?

So I would suggest putting a button to fire the event but if you want to do it that way firing an event every time the text changes isn’t the best in terms of performance so check if the inserted name is the name of a player in the server on the local script with an if statement and if it is then fire the event

Box:GetPropertyChangedSignal["Text"]:Connect(function(txt)

end)

This will work. And personally the part where u check if txt is changed is useless. Just fire the remoteEvent with the txt as a param and check if txt is a players name, if yes then destroy tht plr.Hello