for _, v in pairs(game.Players:GetChildren()) do
local plrGui = v.PlayerGui
local screenGui = plrGui:FindFirstChild("ScreenGui")
if screenGui then
local box = screenGui:FindFirstChild("TextBox")
if box then box:Destroy() end
end
end
You have to loop through all the players and do it for all of them to make it change for all of them.;
Also take this out: plr:Destroy() this would be destroying the player which should cause an error.
This is probably related to the lines game.Players:FindFirstChildWhichIsA("Player") and plr:Destroy(). Honestly I just assumed the first line was supposed to be the LocalPlayer, and the second one the Box UI.
--LocalScript
local Players = game:GetService("Players")
--I assume you wanted to define the local player perfoming the action?
local Player = Players.LocalPlayer --local player running the script
local Box = script.Parent
Box.Changed:Connect(function()
if Box.Text == Player.Name then
print("yes")
game.ReplicatedStorage.RemoteEvent:FireServer()
end
end)
--Server script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
local plrGui = plr:WaitForChild("PlayerGui")
local ScreenGui = plrGui:WaitForChild("ScreenGui")
local Box = ScreenGui.TextBox
Box:Destroy() --I assume you wanted to destroy the box?
--plr.Character:Destroy() --destroys character
--plr:Kick("kick message") --kicks player
end)
No, I just wanted to make an admin panel sort of thing
so basically if I enter a player’s name it kills the player.
Is it possible to make it or not?
thanks
I just noticed you aren’t checking if the users are actual admins on the server, which means exploiters can abuse it, here’s how your server script should look like:
--UserIds of all the in-game admins.
local admins = {game.CreatorId, 0, 1, 2, 3 --[[etc.]]}
--Server script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr1, plr2)
--check if the player is an actual admin
local Victim = game.Players:FindFirstChild(plr2)
if not table.find(admins, plr1.UserId) then
warn(plr1.Name.." is not an admin!")
return
elseif not Victim then
warn(plr2.Name.." is not a player!")
return
end
--this line may error, but it wont effect the script.
Victim.Character.Humanoid.Health = 0
end)
and the client script:
--LocalScript
local Players = game:GetService("Players")
--I assume you wanted to define the local player perfoming the action?
local Player = Players.LocalPlayer --local player running the script
local Box = script.Parent
Box.Changed:Connect(function()
local text = Box.Text
local found = Players:FindFirstChild(text)
if not found then return end
game.ReplicatedStorage.RemoteEvent:FireServer(text)
end)
Well, for that to happen you will have to follow the steps below:
Make a “LocalScript” that will serve as the one that will check the text box (Put “LocalScript” as a child of the TextBox):
local ReplicatedStorage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace: Workspace = game:GetService("Workspace")
local RemoteEvent: RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local TextBox: TextBox = script.Parent
TextBox.Changed:Connect(function(property: any): RBXScriptSignal | any
if type(property) == "string" then
if Workspace:FindFirstChild(TextBox.Text) then
local PlayerForKill = Workspace:FindFirstChild(TextBox.Text)
RemoteEvent:FireServer(PlayerForKill)
end
end
end)
Now create a normal “Script” and put it in “ServerScriptService” so you can manage things:
local ReplicatedStorage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent: RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent.OnServerEvent:Connect(function(Player: Player, PlayerForKill): RBXScriptSignal | any
local GetHumanoid: Humanoid = PlayerForKill:WaitForChild("Humanoid")
GetHumanoid:TakeDamage(math.max(GetHumanoid.MaxHealth, 0))
end)
If you have any questions about the system, please contact me.