在 roblox 中使用商店 GUI 时出错

Getting an error with a shop GUI in roblox

我在 roblox 中有这个商店 gui,当我尝试购买东西时,它总是给我一个错误。我有模型的 link,因此您可以查看它并尝试解决问题。这是出错的代码

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:尝试用 'Clone' 索引 nil 10:16:49.715 - 堆栈开始 10:16:49.715 - 脚本 'Players.kaitheawsomecathoo1.PlayerGui.Shop.Frame.Info.Buy.Script',第 9 行 10:16:49.716 - 堆栈结束

任何帮助都会很棒!如果您需要我更具体地说明任何事情,请告诉我!

这里是模型link

https://www.roblox.com/library/1855829220/Shop-Gui-2018

toolnil

查明原因,仅在工具为有效值时才调用 tool:Clone()