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 2 years ago

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

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

1 answer

Log in to vote
1
Answered by 2 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:

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

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

Answer this question