我正在尝试获得一个自定义库存系统,但由于某种原因,它一直说我的代码中有一个“错误”,我尝试一个,它失败,然后我尝试另一个,没问题,但是在我添加之后另一段代码,它说这是一个错误,这次所有方法都不起作用
我尝试了一切方法来做到这一点,但它不起作用,这就是我现在所拥有的:
local sel = script.Parent.Parent.Frame.Selected
function update()
local sample = game.ReplicatedStorage.inventory.Sample
local player = game.Players.LocalPlayer
local char = player.Character
local items = player:FindFirstChildWhichIsA("Backpack"):GetChildren()
local btn = nil
while script.Parent:FindFirstChild("item") do
script.Parent:FindFirstChild("item"):Destroy()
end
if char:FindFirstChildWhichIsA("Tool") then -- where it for some reason has an "error"
table.insert(items, char:FindFirstChildWhichIsA("Tool"))
end
for i, v in pairs (items) do
if v.ClassName == "Tool" then
btn = sample:Clone()
btn.Name = "item"
btn.Item.Value = v
btn.Sel.Value = sel
btn.Parent = script.Parent
btn.Image = v.TextureId
end
end
end
while true do
wait(0)
if script.Parent.Parent.Visible == false then
update()
end
end