Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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?

0
first of can u format it so it doesn't kill my eyes while looking at it? Xyternal 247 — 2y

1 answer

Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
2 years ago
Edited 2 years ago

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.

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? jsareamazing 0 — 2y
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. MarkedTomato 810 — 2y
Ad

Answer this question