Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I've made a admin and dont know what to put in the game.Players bit? [Solved]

Here is the code

commands.kick = function(sender, arguments)
	
	print("Kick Fired By "..sender.Name)
	
	for _, playerName in pairs(arguments) do
		print(playerName)
	end

    local playerToKick = arguments[1]

    if playerToKick then
	    local plrToK = findPlayer(playerToKick)
	
	    if plrToK then
		    game.Players.    :Kick("Removed From The Server")
	        print("Successfully Removed Player!")
	    end
    end

end

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message,recipient)
		if isAdmin(player) then
			message = string.lower(message)
			
			local splitString = message:split(" ")
			
			local slashCommand = splitString[1]
			
			local cmd = slashCommand:split(prefix)
			
			local cmdName = cmd[2]
			
			if commands[cmdName] then
				
				local arguments = {}
				
				for i = 2, #splitString, 1 do
					table.insert(arguments,splitString[i])
				end
			
			    commands[cmdName](player,arguments)
			
			end
		
		
		end
end)
	end)
	
	
local function findPlayer(name)
	
	for _, player in pairs(game.Players:GetPlayers()) do
		if string.lower(player.Name) == name then
			return player
		end
	end

    return nil

end

local function isAdmin(player)
	for _, v in pairs(admins) do
		if v == player.Name then
			return true
		end
	end

   return false
end

1 answer

game.Players[playerToKick]:Kick("")

Figured it out

This discussion is preserved as it was. New answers, comments, and votes are closed.