I need help with this because I want to have background animations to it after they press cancel or buy it works with PromptGamePassPurchaseFinished (I used the same script but change the PromptGamePassPurchaseFinished) however it's saying
11:13:30.671 - Unable to cast value to Object.
local id = 996037310 local RM = game.ReplicatedStorage.RemoteEvents.DevPurchaseButton game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(player,id,purchased) if not purchased then RM:FireClient(player, purchased) elseif purchased then RM:FireClient(player, purchased) end end)
Firstly, player
in .PromptProductPurchaseFinished
is the player's user id, so it will error. try making player
in .PromptProductPurchaseFinished
as playerId
. So, you need to do:
local plr = game.Players:GetPlayerFromUserId(playerId)
in the .PromptProductPurchaseFinished
event. So, your whole code about it should look like:
local id = 996037310 local RM = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("DevPurchaseButton") game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(playerId, id, purchased) local plr = game.Players:GetPlayerFromUserId(playerId) RM:FireClient(plr, purchased) -- we just did this since you do two checks for the same thing that's gonna happen. Purchased is true if purchased, false if not. You can fire without if/then statements which will make your code alot easier. end)
Hope this helps!