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

Unable to cast Instance to int64?

Hello all, I was experimenting with DataStores.

I made a game pass, and if a player purchases it, the game will save that player's stage.

If the player does not own the game pass, then the game will not save the player's stage.

My issue is with the line below, and the error it's giving is "Unable to cast Instance to int64"

-- Variables:
local marketplaceService = game:GetService('MarketplaceService')
local saveStageId = 11704094

.

game.Players.PlayerRemoving:Connect(function(player)
	if marketplaceService:UserOwnsGamePassAsync(player, saveStageId) then
		SavePlayerData(player)
	end
end)

I'm not even sure what an int64 is myself, so any help would be great appreciated!

1 answer

If you take a look at the api of UserOwnsGamePassAsync it expects the userid not the player so

game.Players.PlayerRemoving:Connect(function(player)
    if marketplaceService:UserOwnsGamePassAsync(player.UserId, saveStageId) then
        SavePlayerData(player)
    end
end)

and int64 is basically a number the error comes from that it tried to cast an instance to a number

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