Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Game pass detection not functioning correctly?

Asked by
Plieax 66
6 years ago

What it should do is fire a remote when the click detector is clicked, the click detector then makes sure the player has the gamepass and if they don't it prompts the purchase for it. Then the local script, when the remote is run will check again if the player has the gamepass(to stop exploiters from just firing the remote) But I get this error on line 11 of the server script:

12:08:15.831 - Unable to cast Instance to int64

Server:

01local this = script.Parent
02local CL = script.Parent.CL
03local mp = game:GetService("GamePassService")
04local remote = game.Lighting.OD
05local mp2 = game:GetService("MarketplaceService")
06 
07CL.MouseClick:Connect(function(plr)
08    if mp:PlayerHasPass(plr,5043985) then
09        remote:FireClient(plr)
10    else
11        mp2:PromptGamePassPurchase(5043985,plr)
12    end
13end)

Local:

1local plr = game.Players.LocalPlayer
2local mp = game:GetService("GamePassService")
3 
4game.Lighting.OD.OnClientEvent:Connect(function()
5    if mp:PlayerHasPass(plr,5043985) then
6        game.Lobby.VIPPART:Destroy()
7    end
8end)
0
u shouldnt put it in lighting put it in replicated storage MineBlow111 39 — 6y
0
^ Griffi0n 315 — 6y

1 answer

Log in to vote
1
Answered by
Griffi0n 315 Moderation Voter
6 years ago
Edited 6 years ago

The first argument of MarketplaceService:PromptGamePassPurchase is a player Instance and the second one is the gamepass id:

1MarketplaceService:PromptProductPurchase(Instance player, int64 gamePassId)

GamePassService:PlayerHasPass should be deprecated but let's treat it like it's deprecated. MarketplaceService:UserOwnsGamePassAsync is the alternative and it works MUCH better.

However it takes different arguments:

1MarketplaceService:UserOwnsGamePassAsync(int64 userId, int64 gamePassId)

Now let's look at the fixed scripts:

Server:

01local clickDetector = script.Parent.CL
02local remote = game.Lighting.OD
03local marketplaceService = game:GetService("MarketplaceService")
04local gamePassId = 5043985
05 
06clickDetector.MouseClick:Connect(function(player)
07    if marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
08remote:FireClient(player)
09    else
10        marketplaceService:PromptGamePassPurchase(player, gamePassId)
11    end
12end)

Client:

01local player = game.Players.LocalPlayer
02local remote = game.Lighting.OD
03local marketplaceService = game:GetService("MarketplaceService")
04local gamePassId = 5043985
05 
06remote.OnClientEvent:Connect(function()
07    if marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
08        workspace.Lobby.VIPPART:Destroy()
09    end
10end)
0
:v User#19524 175 — 6y
Ad

Answer this question