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

Unable to cast Instance to int64 error?

Asked by
Memotag 226 Moderation Voter
5 years ago

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
You're supposed to use the UserId instead of the Player instance, that's why it's giving you that error. RubenKan 3615 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited by User#24403 5 years ago

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

0
"Unable to request Instance to int64" makes no sence. User#24403 69 — 5y
0
Is there any reason why the image of the gamepass no longer appears when you select to buy it? Memotag 226 — 5y
Ad

Answer this question