How to get a person kicked out of the place if he doesn’t have a badge?

Please help i want finish my game

code i totally didnt steal from roblox documentation website

local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")

local badgeId = 00000000 -- Change this to your badge ID

local function onPlayerAdded(player)
	-- Check if the player has the badge
	local success, hasBadge = pcall(function()
		return BadgeService:UserHasBadgeAsync(player.UserId, badgeId)
	end)

	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has badge!")
		return
	end

	if hasBadge then
		-- Handle player's badge ownership as needed
		print(player.Name, "has badge", badgeId)
	else
        player:Kick("YOU DONT HAVE THE BADGGE!!!!!!!!!!!!!!!")
    end
end

-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)

I even asked AI using the OP’s question, and got the same script. I wish people would help theirself before asking on the devforum.

3 Likes


bruh i hate it

I didn’t show the full code it sent.

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