[ProfileService] Not properly banning user

So, I am trying to use ProfileService to ban users and save player data. Although it doesn’t seem to kick the user even when the data in the Dev Console shows the ban being set to “true.”

local ProfileCache = require(game.ServerScriptService.Modules.ProfileCacher)

local function CheckBanned(player)
	local playerProfile = ProfileCache[player]
	if playerProfile~= nil then
		if playerProfile.Data.Banned == true then
			player:Kick("Youve been banned")
			print("[ProfileService]: " .. player.Name .. " has been kicked due to being banned")
		end
	end
end

game.Players.PlayerAdded:Connect(CheckBanned)


1 Like

Inside your CheckBanned function, put prints to see if playerProfile is nil and the other if statements. You are activating that function as soon as the player joins. It should be activated when data is loaded instead.

2 Likes

Thanks, I waited until the player fully loaded in and added a check to ensure player data has loaded then it checks if the user is banned. Again, thank you.

1 Like