我观看了有关如何在Roblox中创建捐赠按钮的YouTube视频,并按照步骤进行操作。但是当我使用它时,它给了我很多错误。
我尝试将.connect
更改为:Connect
,但它给了我更多的错误,我尝试将end)
更改为end
,但这给了我更多的错误。
代码:
local id = 459818680
script.Parent.TextButton.MouseButton1Click.connect()(function()
game:GetService("MarketplaceService"):PromptProductPurchase
(game.Players.LocalPlayer, id)
end)
我希望能够在测试时单击它,然后会弹出一个购买菜单。没啥事儿。我也有这样的错误:
Players.ImNotKevPlayz.PlayerGui.ScreenGui.LocalScript:4:“连接”参数错误1(期望RBXScriptSignal,没有值)
当我在Roblox命令中尝试调试命令时,它给了我这个错误:
脚本错误:“ =”应在“
附近
答案 0 :(得分:0)
Heyo,您的脚本几乎可以正常运行,看起来只是您遇到了一些语法错误。
bad argument #1 to 'connect' (RBXScriptSignal expected, got no value)
这意味着MouseButton1:Connect函数需要一个参数,但是您什么也没给。
尝试此修复程序:
local id = 459818680
local targetButton = script.Parent.TextButton
local MarketplaceService = game:GetService("MarketplaceService")
targetButton.MouseButton1Click:Connect(function() -- <-- this just needed to be fixed
local player = game.Players.LocalPlayer
MarketplaceService:PromptProductPurchase(player, id)
end)