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

[SOLVED] How do I fix the 'Unable to cast int64 error'?

Asked by 2 years ago
Edited by Leamir 2 years ago

This question has been solved by the original poster.

I'm trying to make a gamepass, and make it see if the player owns the gamepass, if not then a gamepass will get prompted.

Here is my script (it's a local script):

local gamepassID = 49956565
local MPS = game:GetService('MarketplaceService')

local plr = game.Players.LocalPlayer
local button = plr.PlayerGui.GamepassShopGUI.MainFrame.TwoTimesClicksFrame.BuyButton

button.Activated:Connect(function()
    if MPS:UserOwnsGamePassAsync(plr, gamepassID) then
        button.Text = 'You already own the gamepass'
    else
        MPS:PromptGamePassPurchase(plr, gamepassID)
    end
end)

The error is on line 8.

Thank you for reading.

0
The first argument to `UserOwnsGamePassAsync()` should be the player's user id, not the player object. Also, this more than likely needs to be handled in a server-side script. ScriptGuider 5640 — 2y
0
I need to do it when a player presses a gui button, so I used a remote event, but now it says "Unable to cast value to Object" starranger4 4 — 2y
0
I have found out the answer now. starranger4 4 — 2y
0
Hey Buddy make sure the game pass features giving script is in ServerScriptService in case of Exploiters. Hi_People1133 218 — 2y
0
Please remember to add "[SOLVED]" to your question title when you resolve it without accepting any answers. Thanks Leamir 3138 — 2y

Answer this question