Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a way to have a badge from one game unlock an area in another game?

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?

1 comment

0

first of can u format it so it doesn't kill my eyes while looking at it?

1 answer

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.

2 comments

0

This does work, but when someone who does not own the badge also joins, they can still access the area, is there a way to make it so only on the badge owner's screen it's unlocked?

0

UserHasBadge is deprecated and shouldn't be used. UserHasBadgeAsync should be used instead. Also make sure to wrap it in a pcall since it sends a query to the roblox website.

This discussion is preserved as it was. New answers, comments, and votes are closed.