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

How to make a "Check if user has a Badge then..." ?

Asked by 4 years ago

--I'm doing an Egg Hunt 2020 Helper Game Everything is already working but, i want to make like... if you have the badge of the egg of a certain game, the red portal will turn into green.

Please help, i'm trying to make my friend get all the eggs.

I think its something like that ~~~~~~~~~~~~~~~~~ if game.workspace. ???? ???? -- that's all i can think of. ~~~~~~~~~~~~~~~~~

Please help before: april 28th

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You can use BadgeService’s :UserHasBadgeAsync() method to verify whether a Player owns a Badge. This method will require two arguments, that of which is the AssetId of the Badge, and the UserId of the Player to uplink the account for confirmation.

This function’s return type is a boolean, therefore we can use it in conjunction with a conditional statement.

local BadgeService = game:GetService("BadgeService")
local BadgeId = --// ID

local Player = game:GetService("Players").LocalPlayer

if (BadgeService:UserHasBadgeAsync(BadgeId, Player.UserId) then
    --// Adjust BrickColor of BasePart to green.
end

Remember to accept this answer if it helps!

Ad

Answer this question