我一直在学习制作roblox游戏,但最近我遇到了一个问题,代码是正确的,但它不起作用
我是按照这个roblox网站做的。
但即使我做了类似的事情,它也不起作用。有人能纠正我哪里错了吗?
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local donateEvent = ReplicatedStorage:WaitForChild("donateEvent")
local ProductFunctions = {}
ProductFunctions[1249752191] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752535] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752534] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752537] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752533] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752530] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752532] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752536] = function(Player)
donateEvent:FireClient(Player)
end
ProductFunctions[1249752531] = function(Player)
donateEvent:FireClient(Player)
end
MarketPlaceService.ProcessReceipt = function(info)
local Player = Players:GetPlayerByUserId(info.PlayerId)
local Product = info.PurchaseId
if not Player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local success, err = pcall(ProductFunctions[Product],Player)
if not success then
warn('error')
return Enum.ProductPurchaseDecision.NotProcessedYet
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
我的问题是,即使流程收据在那里,并且ID与要检查的给定值完全匹配。函数内部的事件根本没有启动!他们中甚至没有一个事件被触发。。。
问题是我写了
local Product = info.PurchaseId
实际上应该是
local Product = info.ProductId