#NEED HELP WITH GAMEPASS
1 messages · Page 1 of 1 (latest)
local UnlockIndex = game.ReplicatedStorage.UnlockIndex
local MarketplaceService = game:GetService("MarketplaceService")
local function onPlayerAdded(Player)
local success, OwnsAsset =
pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, Player, 1730820105)
if not success then
local errorMessage = OwnsAsset
warn("Error Code: 4")
return
end
if OwnsAsset then
UnlockIndex:FireClient(Player, "Shiny")
local Character = Player.Character or Player.CharacterAdded:Wait()
if Character then
Character:WaitForChild("HumanoidRootPart"):WaitForChild("TagUI").Vip.Visible = true
end
print(Player.Name.. " owns VIP.")
else
print(Player.Name.." does not own VIP.")
end
end
Players.PlayerAdded:Connect(onPlayerAdded)```
?
I made this server script that should check if the player owns a gamepass and fire [equip] and make one thing visible. The problem is it says i dont own the gamepass even if i do
basically prints "does not own VIP."
i, as the creator of the gamepass should own it automatically right?
so it should instantly count me as a VIP
I quickly searched and it says that you do not automaticly own them
and that you'd have to purchase them.
But i think in studio testing you can purchase gamepasses for free
well thats true but since it takes effect AFTER i rejoin and my purchases dont save i cant actaully test it without paying
not liek i dont have robux for that but still
cuz it checks only when playeradded
then check after you purchase
with real robux?
nah in studios
how do i do that
if you prompt a purchase in studios it should be for free
by checking if they own the gamepass like you did on join
yes but how do i know they just purchased it
like ik how to check if they own it
but i dont know when they purchase the thing
After you prompt your purchase you can just check if they own it the same way you checked it after they joined
wait
MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
end)```
so after the promptgamepasspurchast?
so i send a binable event after this so server?
and just fire this function
wait no it has to be remote event
Yeah
well i guess you could
idk why but it marks it red
MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
PurchasedVIP:FireServer()
end)```
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UnlockIndex = ReplicatedStorage.UnlockIndex
local PurchasedVIP = ReplicatedStorage.PurchasedVIP
local MarketplaceService = game:GetService("MarketplaceService")
local function PlayerOwnsVIP(Player)
local success, OwnsAsset =
pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, Player, 1730820105)
if not success then
local errorMessage = OwnsAsset
warn("Error Code: 4")
return
end
if OwnsAsset then
UnlockIndex:FireClient(Player, "Shiny")
local Character = Player.Character or Player.CharacterAdded:Wait()
if Character then
Character:WaitForChild("HumanoidRootPart"):WaitForChild("TagUI").Vip.Visible = true
end
print(Player.Name.. " owns VIP.")
else
print(Player.Name.." does not own VIP.")
end
end
PurchasedVIP:OnServerEvent:Connect(function(Player)
PlayerOwnsVIP(Player)
end)
Players.PlayerAdded:Connect(PlayerOwnsVIP)```
@viral coral
Well im not quite sure because i never used the MarketplaceService but it feels like ```lua
pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, Player, 1730820105)
Should be:
```lua
pcall(MarketplaceService.PlayerOwnsAssetAsync(Player, 1730820105))
but it marks red the PurchasedVIP:OnServerEvent
bruh
its PurchasedVIP.OnServerEvent:Connect()
Not ```
PurchasedVIP:OnServerEvent:Connect()
oh
wait but if i do this then doesnt it check right when the prompt opens before the player even makes the purchase shouldnt i use something to wait before the player actaully makes purchase?
@viral coral
Yeah your right.
It looks like a event that fires when a purchase for a game pass is finished
ok
MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
if MarketplaceService:PromptGamepassPurchaseFinished(Player, GamepassID) then
PurchasedVIP:FireServer()
end
end)```
like this?
@viral coral
no its a event
and you need to listen to it on the server
oh
it is actaully this one
wait no
pcall(MarketplaceService:PlayerOwnsAssetAsync(Player, 1730820105))
this has :
yeah that might be a method
Anyways i gotta go now. Just try reading through the MarketPlaceService docs or try to watch a tutorial i'll be gone for maybe 40 min or even till tomorrow
apparently theres an error with pcall
@viral coral got time?
Yeah now i do
well idk im getting this error
Well I normaly don't use pcalls like that but i just quickly went over the syntax
Instead of ```lua
local success, OwnsAsset = pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, Player, 1730820105)
Do ```lua
local success, OwnsAsset = pcall(MarketplaceService:PlayerOwnsAssetAsync, Player, 1730820105)
Because after the first Parameter the pcall function expects a Tuple (More parameters) for the given function in the first parameter
local success, OwnsAsset = pcall(MarketplaceService:PlayerOwnsAssetAsync, Player, 1730820105)
if not success then
local errorMessage = OwnsAsset
warn("Error Code: 4")
return
end
if OwnsAsset then
UnlockIndex:FireClient(Player, "Shiny")
local Character = Player.Character or Player.CharacterAdded:Wait()
if Character then
Character:WaitForChild("HumanoidRootPart"):WaitForChild("TagUI").Vip.Visible = true
end
print(Player.Name.. " owns VIP.")
else
print(Player.Name.." does not own VIP.")
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
doesnt work
i think you forgor Mareketplace:PlayerOwnsAssetAsync**()**
also error: argument 2 missing or nil
@viral coral
well. I guess just do this then:
local success, OwnsAsset = pcall(function()
return MarketplaceService:PlayerOwnsAssetAsync(Player, 1730820105)
end)
Atleast that is how I usually use pcalls
listen to this guy hes good
i am