[SOLVED] "Unable to cast instance to int64" fix?
Asked by
5 years ago Edited 5 years ago
This question has been solved by the original poster.
I'm making a gamepass that allows a player to sell ores from anywhere when the player clicks a button in a GUI. Since TextButtons usually use LocalScripts, I have to use remote events to affect the players money across the whole server. However, I've come across an issue. The error states "Unable to cast instance to int64", here's the script:
01 | local btn = script.Parent |
03 | local plr = game.Players.LocalPlayer |
05 | local service = game:GetService( "MarketplaceService" ) |
06 | local event = game.ReplicatedStorage.Events.SellOres |
08 | btn.MouseButton 1 Down:Connect( function () |
11 | if service:UserOwnsGamePassAsync(plr, id) then |
12 | local amount = plr.leaderstats [ "Ore Value" ] .Value |
13 | event:FireServer(amount) |
15 | service:PromptGamePassPurchase(plr, id) |
I know that the error means that what I'm doing is sort of like doing "part + 1", which doesn't make sense. But I don't know what I've done wrong in the script. Please help me if you know the answer, thanks!
Edit: Literally right after I post this I go back to the studio and then remember that I have another script that makes the same statement, so I open that up and realize that I have to use the player's UserId, not the player himself. Whoops!