I want to make it so specific levels are blocked off unless you have certain badges in my platformer. I tried using the wiki, "Restricted Door" tutorial, and it didn't make sense to me. Is there any help I can get?
This is the script from the wiki.
local door = script.Parent function open() -- This function will open the door. door.CanCollide = false -- Make players able to walk through the door. for transparency = 0, 1, .1 do door.Transparency = transparency wait(.1) end end function close() -- This function will close the door. for transparency = 1, 0, -.1 do door.Transparency = transparency wait(.1) end door.CanCollide = true -- Make players unable to walk through the door. end -- This function returns the player a certain part belongs to. function get_player(part) --iterate over each player for _, player in ipairs(game.Players:GetPlayers()) do --if the part is within the player's character if part:IsDescendantOf(player.Character) then --return the player return player end end end door.Touched:connect(function(part) -- If it isn't a character that touched the door, then we ignore it. local player = get_player(part) if not player then return end local allow = ( player.Name == "MrDoomBringer" or player.Name == "JulienDethurens" or player.Name == "blocco" or player.Name == "NXTBoy" or player:IsInGroup(127081) and player:IsFriendsWith(game.CreatorId) or -- This demonstrates how you can use 'and' to combine two restrictions. game:GetService('BadgeService'):UserHasBadge(player.userId, 1032571) or game.CreatorId == player.userId ) if allow then open() delay(4, close) end end)~~~~~~~~~~~~~~~~~ and here is the part for the badges
local BadgeService = game:GetService("BadgeService") local BadgeId = 123
game:GetService("Players").PlayerAdded:connect(function(player) if BadgeService:UserHasBadge(player.UserId, BadgeId) then print("The user has this badge") else print("The user does not have this badge") end end)~~~~~~~~~~~~~~~~~
all I need is an explanation.