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

My player badge detecting script is not working?

Asked by 3 years ago

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

1UserId = game.Players.LocalPlayer.UserId
2 
3local BadgeService = game:GetService("BadgeService")
4 
5if BadgeService:UserHasBadgeAsync(UserId, 2124700001) then
6workspace.everything.tom2.tom3.BrickColor = BrickColor.new("Sea green")
7end

In a localscript in startergui

0
thats the problem. badgeservice uses serverscript not local script TheUltimateTNTFriend 109 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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:

1game.Players.PlayerAdded:Connect(function(Plr)
2    local UserId = Plr.UserId
3    local BadgeService = game:GetService("BadgeService")
4 
5    if BadgeService:UserHasBadgeAsync(UserId, 2124700001) then
6game.ReplicatedStorage.Blahblah:FireClient(Plr)
7 
8    end
9end)

Local script: (parented as parent being its ancestor)

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

hope this helped

0
Thank you so much! It works now! I've been trying to figure this out for hours! User#39520 0 — 3y
0
You have been upvoted! User#39520 0 — 3y
Ad

Answer this question