I have secrets in my game and a gamepass to be able to know where they are with a billboard UI, this script SHOULD make the billboard UIs enabled if they own the gamepass, and keep it disabled (so dont do anything) if they dont. (only for them so client side)
this is located in a local script in StarterplayerGui
it doesnt work.
local gamepassId = 9248266
local part = game.Workspace:WaitForChild("SecretUI")
local function onPlayerJoin(player)
local hasGamepass = false
pcall(function()
hasGamepass = player:HasPass(gamepassId)
end)
if hasGamepass then
for _, child in pairs(part:GetChildren()) do
if child:IsA("BillboardGui") then
child.Enabled = true
if player:IsA("Player") then
child.Enabled = player
end
end
end
end
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
so like as in client sided just put this in a local script, right?
as for the script, like this? it doesnt work
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 9248266
local part = game.Workspace:WaitForChild("SecretUI")
local function onPlayerJoin(player)
local hasGamepass = false
pcall(function()
hasGamepass = MarketplaceService:UserOwnsGamepassAsync(player.UserId, gamepassId)
end)
if hasGamepass then
for _, child in pairs(part:GetChildren()) do
if child:IsA("BillboardGui") then
child.Enabled = true
if player:IsA("Player") then
child.Enabled = player
end
end
end
end
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
I think you need to use UserOwnsGamepassAsync server-side, and maybe use a RemoteEvent to tell the client if they own it. Also check those parameters because I can’t remember if it’s a player object or UserId.