【发布时间】:2020-07-31 03:59:34
【问题描述】:
我在 roblox 中有这个商店 gui,当我尝试购买东西时,它总是给我一个错误。我有模型的链接,因此您可以查看它并尝试解决问题。这是出错的代码
local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = tools:FindFirstChild(script.Parent.Parent.ItemName.Value)
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
if player.leaderstats:FindFirstChild("Coins").Value >= price.Value then -- Change "Money" to the name of your currency. Example: Cash
player.leaderstats:FindFirstChild("Coins").Value = player.leaderstats:FindFirstChild("Coins").Value - price.Value
local clone = tool:Clone()
clone.Parent = player.Backpack
-- Copy this code if you want the player to still have the tool even if he died
local clone2 = tool:Clone()
clone2.Parent = player.StarterGear
end
end)
这是它给我的错误。
10:16:49.715 - Players.kaitheawsomecathoo1.PlayerGui.Shop.Frame.Info.Buy.Script:9:尝试使用“克隆”索引 nil 10:16:49.715 - 堆栈开始 10:16:49.715 - 脚本“Players.kaitheawsomecathoo1.PlayerGui.Shop.Frame.Info.Buy.Script”,第 9 行 10:16:49.716 - 堆栈结束
任何帮助都会很棒!如果您需要我更具体地说明任何事情,请告诉我!
这是模型的链接
【问题讨论】: