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

My player badge detecting script is not working?

I need a brickcolor to change when I have a badge but its not working

UserId = game.Players.LocalPlayer.UserId

local BadgeService = game:GetService("BadgeService")

if BadgeService:UserHasBadgeAsync(UserId, 2124700001) then
workspace.everything.tom2.tom3.BrickColor = BrickColor.new("Sea green")
end

In a localscript in startergui

1 comment

0

thats the problem. badgeservice uses serverscript not local script

1 answer

✓ Accepted answer

The problem is that badgeservice uses a serverscript not a local script. Something you can do however is to make a server script to check if the player meets the requirements, Then send a fireclient request from a remoteevent for the local script to change the things for that player only, Just keep in mind that the local script should be parented to starterplayer scripts A example is like Server Script:

game.Players.PlayerAdded:Connect(function(Plr)
	local UserId = Plr.UserId
	local BadgeService = game:GetService("BadgeService")
	 
	if BadgeService:UserHasBadgeAsync(UserId, 2124700001) then
game.ReplicatedStorage.Blahblah:FireClient(Plr)
	
	end
end)

Local script: (parented as parent being its ancestor)

game.ReplicatedStorage.Blahblah.OnClientEvent:Connect(function()
workspace.everything.tom2.tom3.BrickColor = BrickColor.new("Sea green")
end)

hope this helped

2 comments

0

Thank you so much! It works now! I've been trying to figure this out for hours!

0

You have been upvoted!

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