Lua roblox中的商店GUI出错
我有一个roblox中的商店gui,当我尝试买东西时,它总是给我一个错误。我有模型的链接,所以你可以看看它,并尝试解决这个问题。这就是出错的代码Lua roblox中的商店GUI出错,lua,roblox,Lua,Roblox,我有一个roblox中的商店gui,当我尝试买东西时,它总是给我一个错误。我有模型的链接,所以你可以看看它,并尝试解决这个问题。这就是出错的代码 local price = script.Parent.Parent.Price local tools = game.ReplicatedStorage:WaitForChild("Tools") local tool = tools:FindFirstChild(script.Parent.Parent.ItemName.Value) local
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-烟囱末端
任何帮助都会很好!如果你需要我在任何事情上更具体的话,请告诉我
这是模型的链接
工具
为nil
找出原因并仅在工具是有效值时调用
tool:Clone()
。工具不是有效工具。所以,每次我需要不同的工具时,是否需要调用不同的工具?tool
是一个nil值,在对其进行索引之前,必须检查它是否为nil