如何在购买DevProduct(Roblox LUA)时触发某些事件

我已经完成了代码的主要部分,但在重要的部分卡住了。这是我在做什么:

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local productID = 1218445231
local productInfo = MarketplaceService:GetProductInfo(productID, Enum.InfoType.Product)
script.Parent.MouseButton1Click:Connect(function()
    local function promptPurchase()
        local player = Players.LocalPlayer
        MarketplaceService:PromptProductPurchase(player, productID)
        purchased = true
    end
end)
if purchased == true then
 --这里卡住了(如果你不理解,我制作的海啸应该变得可见并开始朝着地图移动,但这部分在“Workspace”中,按钮在“StarterGUI”中,请帮助我。)
end

编辑:现在更新了代码,仍然不知道该怎么办。我该获得Workspace服务吗?如果是这样,我该如何编写代码将海啸的透明度设置为“0”,并开始移动?这是我的代码:

local MarketplaceService = game:GetService("MarketplaceService")
local player = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PurchaseEvent = ReplicatedStorage.PurchaseEvent
local productID = 1218445231


script.Parent.MouseButton1Click:Connect(function()

    PurchaseEvent:FireServer(productID)
end)

if MarketplaceService:PlayerOwnsAsset(1218445231) then
    --使海啸可见并开始移动
end

原文链接 https://stackoverflow.com/questions/69867801

点赞