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

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

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

✓ Accepted answer

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.

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