Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to cast Instance to int64 error?

I keep getting Unable to cast Instance to int64 errors whenever I run this script and I don’t know how to go about fixing this.

local passId = 6390

game.Players.PlayerAdded:Connect(function(plr)
if isAuthenticated(plr) then
script.Parent.Parent:Destroy()
end
end)

function isAuthenticated(player)
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, passId)
end

The script is in a GUI where the user clicks to buy a gamepass.
Also, whenever you click the button, the prompt that appears no longer shows the image of the gamepass so how can I fix that too?

At the moment the error appears to come from line 10

Thank you

1 comment

1

You're supposed to use the UserId instead of the Player instance, that's why it's giving you that error.

1 answer

✓ Accepted answer

To RubenKan's suggestion...

local passId = 6390

game.Players.PlayerAdded:Connect(function(plr)
if isAuthenticated(plr.UserId) then
script.Parent.Parent:Destroy()
end
end)

function isAuthenticated(player)
return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, passId)
end

An int64 is a number. A plr is an Instance.

It requests an int64, not an Instance. Cast = Changing from one datatype to another

2 comments

0

"Unable to request Instance to int64" makes no sence.

0

Is there any reason why the image of the gamepass no longer appears when you select to buy it?

This discussion is preserved as it was. New answers, comments, and votes are closed.