This is my script.
door = script.Parent badgeholder = door.Parent.BadgeID.Value local badgeservice = game:GetService("BadgeService")
function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then local p = game.Players:GetPlayerFromCharacter(hit.Parent) if p then if badgeservice:UserHasBadgeAsync(p.UserId, badgeholder) then door.Transparency = 0.8 door.CanCollide = false wait(0.3) door.Transparency = 0.5 door.CanCollide = true else hit.Parent.Humanoid.Health = 0 end end end end
door.Touched:connect(onTouched)
Do I have to change it in a way so that it can work from another game?
Try using this script, it'll walk you through the steps.
local BadgeService = game:GetService("BadgeService") -- calls BadgeService. local BadgeId = 123 -- your badgeID game:GetService("Players").PlayerAdded:Connect(function(player) -- Gets you, or your player. if BadgeService:UserHasBadge(player.UserId, BadgeId) then -- checks to see if you have badge. print("The user has this badge") --Tells you whether you do or do not. This is also where you can put your unlock section script. else print("The user does not have this badge") end end) --ends script.
You can put this in any game, and this is a server script.