Hey developers, I am working on a gui that would show a Buildersclub Badge next to the player’s username on the leaderstat gui when they bought this buildersclub gamepass. The script however doesn’t work and I have absolutely no idea why. So basically it keeps passing down a true value while a player doesn’t even have this gamepass.
- Script:
local checkBuildersclubEvent = game:GetService("ReplicatedStorage").Events:WaitForChild("CheckBuildersclubEvent")
local BUILDERS_CLUB_GAMEPASS_ID = 981466084
checkBuildersclubEvent.OnServerInvoke = function(player)
local hasBuildersClub = false
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, BUILDERS_CLUB_GAMEPASS_ID) then
hasBuildersClub = true
end
return hasBuildersClub
end
- Localscript:
local function onPlayerAdded(player)
local playerState = {}
local name = player.Name
local lbl = basePlayerLbl:Clone()
lbl.Name = name
lbl.PlayerName.Text = name
lbl.PlayerName.TextColor3 = computePlayerColor(player)
task.defer(function()
if player:IsInGroup(groupId) then
lbl.Badges.JoinedClubBadge.Visible = true
end
task.defer(function()
local checkBuildersclubEvent = game:GetService("ReplicatedStorage"):WaitForChild("Events"):FindFirstChild("CheckBuildersclubEvent")
local hasBuildersclub = checkBuildersclubEvent:InvokeServer(player)
if hasBuildersclub then
print("Player: "..player.Name.." and HasBuildersclub = ".. tostring(hasBuildersclub))
lbl.Badges.BuildersclubBadge.Visible = true
else
print("Player: "..player.Name.." and HasBuildersclub = ".. tostring(hasBuildersclub))
lbl.Badges.BuildersclubBadge.Visible = false
end
end)
if player.UserId == 2679184518 then
lbl.Badges.OwnerBadge.Visible = true
end
end)
lbl.Parent = coreGroup
playerState.Player = player
playerState.Label = lbl
playerState.Stats = {}
playerStates[player] = playerState
for _,child in pairs(player:GetChildren()) do
onPlayerChildAdded(child)
end
player.ChildAdded:Connect(onPlayerChildAdded)
player.ChildRemoved:Connect(onPlayerChildRemoved)
player.Changed:Connect(function (property)
if property == "Team" then
ePlayerTeamChanged:Fire(player)
end
end)
ePlayerTeamChanged:Fire(player)
end