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:
local btn = script.Parent
local db = true
local plr = game.Players.LocalPlayer
local id = 7596478
local service = game:GetService("MarketplaceService")
local event = game.ReplicatedStorage.Events.SellOres
btn.MouseButton1Down:Connect(function()
if db == true then
db = false
if service:UserOwnsGamePassAsync(plr, id) then --this should change from (plr, id) to (plr.UserId, id)
local amount = plr.leaderstats["Ore Value"].Value
event:FireServer(amount)
else
service:PromptGamePassPurchase(plr, id)
end
wait(0.1)
db = true
end
end)
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!
