I've created an admin-only surface GUI, and one of the buttons kills all players. The script is as follows:
script.Parent.MouseButton1Click:connect(function() local P = game.Players:GetChildren() for i = 1, #P do wait() P[i].Character.Head:Remove() end end)
I was wondering if it would be possible to check if the players name is X (X being a predetermined name of an admin (or admins?)) and if so, then don't kill that player, else, if it isn't the name of an admin, kill the player. Would you have any idea as to how I would incorporate that into this for loop? Thanks for any and all help! Cheers!
You would simply make sure that it isn't the admin that the for loop is about to kill, before proceeding with the actual killing
script.Parent.MouseButton1Click:connect(function() local P = game.Players:GetChildren() for i = 1, #P do wait() if not (Character.Name == ADMIM_NAME_HERE) then --IF this is NOT the admin, then kill the specified character. P[i].Character.Head:Remove() end end end)
Try this
script.Parent.MouseButton1Click:connect(function() local P = game.Players.LocalPlayer if P.Character.Name == 'adminname' then whatever you want to happen else P.Character.Humanoid.Health = 0 end end)