I set up a remote event to handle purchases for my game because it makes me feel neater and I'm getting "unable to cast instance to int64" in the dev console the script causing this error is: and the error occurs on line 7 and line 23
local MPService = game:GetService("MarketplaceService") local HttpService = game:GetService("HttpService") local Webhook = "empty because one of the reasons im using a remote event is security" local event = game.ReplicatedStorage.hey event.OnServerEvent:Connect(function(player, assetId) promptpurchase(player, assetId) end) function GetSales(assetId) local data = HttpService:JSONDecode(HttpService:GetAsync("https://api.roblox.com/Marketplace/ProductInfo?assetId="..assetId)) local sales = data.Sales return(sales) end function GetName(assetId) local data = HttpService:JSONDecode(HttpService:GetAsync("https://api.roblox.com/Marketplace/ProductInfo?assetId="..assetId)) local name = data.Name return(name) end function promptpurchase(player, assetId) MPService:PromptPurchase(player, assetId) MPService.PromptPurchaseFinished:connect(function(Player, assetID, isPurchased) if isPurchased then local HookData = { ['username'] = "shop", ['content'] = "Player: "..player.Name.."\nAsset Bought: "..assetId" } HookData = HttpService:JSONEncode(HookData) HttpService:PostAsync(Webhook, HookData) end end) end
I've literally tried every possible thing I could think of, but lua's a very confusing language to me sometimes with the errors I get.
anyone got any ideas?
edit: some of you asked for what i was inputting as params so here it is:
game.ReplicatedStorage.hey:FireServer(game.Players.LocalPlayer, 320412452)
Your error literally means that you are trying to store an object (like a "player" or "part" or "model") into a number storage container (basically like doing "part" + 1 which doesn't make sense). Sorry if that didn't make sense because I don't know how to word it right but I hope I can at least give you an idea with the "part" + 1 thing.
My best guess is that when you are passing in the gamepass's ID through the event, you are actually giving it the object itself rather than a number (which is the gamepass's ID). Would be more useful if you can show us your other script that calls the event to trigger this.
Just make sure to check if you are not sending anything else than a number for the second parameter when you prompt the purchase (the gamepass ID).
If you have any questions or issues, please contact me (as this may not be the solution). ;)