I was looking everywhere on the internet and i couldn't Find it so i decided to ask here. So i'm trying to make an admin script everything is going good but there's one problem. How do i get peoples Names by using find first child? my name is oskar2266001 so if i want to type ;ban osk it would ban me? Please help here's the code.

wait(3)

local Admin = "oskar2266001"

local BanList = Instance.new("Folder",game.ReplicatedStorage)

local Prefix = ";"

  

BanList.Name = "BanList"

  

  

local Players = game:GetService("Players")

for i, player in pairs(Players:GetPlayers()) do

    if player.Name == Admin then

	    game.Players[Admin].Chatted:connect(function(msg)

		    if msg == Prefix.."shutdown" then

		    for i, player in pairs(Players:GetPlayers()) do

		    game.Players[player.Name]:Kick("The Game was Shutdown By "..Admin)

    end

end


if msg:sub(1, 6) == Prefix.."kill " then

    local Target = game.Players:FindFirstChild(msg:sub(7))
    
	    if Target then
	    
		    local Character = Target.Character
	    
		    if Character then
	    
		    Character.Humanoid.Health = 0
	    
	    end
    
    end
    
end


if msg:sub(1, 6) == Prefix.."kick " then

    local Target = game.Players:FindFirstChild(msg:sub(7))
    
		    if Target then
		    
		    Target:Kick("You have Been Kicked By "..Admin)
		    
		    end
		    
		    end
    
	    end)
    
    end

end

1 comment