Get username with a few characters via a function

So i got a custom admin panel, And i want to add an autofill to it.
And i want to test it on my kick/ban/unban script.

RE2.OnServerEvent:Connect(function(player, Username, Reason, Type)
	local UserId = game.Players:GetUserIdFromNameAsync(Username)
	if table.find(Allowed, player.UserId) or admins:GetAsync(player.UserId) then
		if game.Players:FindFirstChild(Username)  and Type == "Kick" then
			game.Players:FindFirstChild(Username):Kick(Reason)
		elseif Type=="Ban" and not table.find(Allowed, UserId) or not admins:GetAsync(UserId) then
			bds:SetAsync(UserId, true)
			if game.Players:FindFirstChild(Username) then
				game.Players:FindFirstChild(Username):Kick("You have been banned from this game. Reason: "..Reason)
			else
				print("User is not in server!")
			end
		elseif Type=="Unban" then
			bds:SetAsync(UserId, false)
		elseif table.find(Allowed, UserId) or admins:GetAsync(UserId) then
			RE4:FireClient(player, "Admin System", "Sorry buddy, Can't ban "..tostring(Username)..", They are an admin.", 5)
		end
	elseif not table.find(Allowed, player.UserId) and not admins:GetAsync(player.UserId) then
		bds:SetAsync(Username,true)
		if Type=="Kick" then
			player:Kick("nice try "..Type.."ing someone ya big exploiter")
			Reason="Exploiting"
		else
			player:Kick("nice try "..Type.."ning someone ya big exploiter")
			Reason="Exploiting"
		end
	end
	banreason:SetAsync(UserId, Reason)
end)

This is the full code of a piece of the admin panel script.
Help is highly appreciated.

i got it to work
this makes me happy

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.