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

How would I make something appear locally when the player has a badge?

Asked by 2 years ago

Im trying to make a script where if a player has a badge a trophy will appear locally. I've tried and failed and was hoping someone could help!

local BadgeService = game:GetService("BadgeService")
local player = game.Players.LocalPlayer

game.Players.PlayerAdded:Connect(function()
    if BadgeService:UserHasBadgeAsync(player.UserId, 2124675902) then
        print(player.. "Has Badge")
        script.Parent.Union.Transparency = 0
    end
end)

Thank you in advanced!

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

I would use a Remote Event in this case. (Search up remote events if you don't know what they do)

Copy the same code and put it in a normal script

local BadgeService = game:GetService("BadgeService")
    local player = game.Players.LocalPlayer

    game.Players.PlayerAdded:Connect(function()
        if BadgeService:UserHasBadgeAsync(player.UserId, 2124675902) then
            print(player.. "Has Badge")
        end
    end)

Get rid of the transparency part though in the normal script, now though fire a remote event and have the local script catch that and make the part transparent. (SEARCH UP REMOTE EVENTS IF YOU DON'T KNOW WHAT YOU'RE DOING)

Problems with this solution: Exploiters can fire remote events which is a big security issue that you have to solve. Ways I would counter this is have the local script check if the player has a badge but I'm not sure if the local script can do that. Another temp solution would be to create a value and make the server script change that to 1 and have the local script check if the value is 1 but exploiters can also change values so idk what to do here.

Although if the trophy is cosmetic I guess it wouldn't matter if exploiters could make it non-transparent since it would do nothing.

Ad

Answer this question