You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
Okay, so im making a emote gui, and i added premium Gamepass only emotes, but i have a issue with the Textbutton locker, so when the player joins and owns the gamepass it should automatically dissappear, the thing is i don’t know where to implementgame:GetService("Players").PlayerAdded:Connect(function(plr)
and if the player doesn’t own it, works good.
- What is the issue? Include screenshots / videos if possible!
so all works, just is that i want to add a function that checks when a player joins, if own the pass, if they do, then the Parent.Visible = false, but i tried to implement it, but it bugs out
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i Tried debugging but i think the problem is on “script.Parent.MouseButton1Click:Connect(function()”
that causes that when the player that owns the gamepass need to click it to unlock, but i want it to happen when the player joins (like it detects that the player joins, and if he have the gamepass bought then visible = false)
local MarketplaceService = game:GetService("MarketplaceService")
local PurchaseAdvert = script.Parent.Parent.Parent.PurchaseAdvert
local gamePassId = 222426001
local function CheckGamePass(player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
script.Parent.Visible = false
print("Player owns the game pass. Button hidden.")
else
print("Prompting game pass purchase...")
MarketplaceService:PromptGamePassPurchase(player, gamePassId)
PurchaseAdvert.Visible = true
end
end
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
if player then
print("Player is logged in.")
CheckGamePass(player)
else
print("Waiting for player to join...")
end
end)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess and purchasedPassId == gamePassId then
script.Parent.Visible = false
print("Player successfully purchased the game pass. Button hidden.")
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.