【发布时间】:2022-06-17 19:46:03
【问题描述】:
基本上,我不确定如何在第 4 行和第 27 行定义项目。如果有人可以帮助我,那就太好了。它只是在输出中说,未知的全局“项目”
for i,v in pairs(Buttons:GetChildren()) do
local NewItem = BoughtItems:FindFirstChild(v.Item.Value)
if NewItem ~= nil then
Items[NewItem.Name] = NewItem:Clone()
NewItem:Destroy()
else
v.Transparency = 1
v.CanCollide = false
end
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function()
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
if BoughtItems:WaitForChild(v.Dependency.Value, 100000) then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
end
end))
end
v.ButtonPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Values.OwnerValue.Value == Player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
if Player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
Player.leaderstats.Cash.Value -= v.Price.Value
Items[v.Item.Value].Parent = BoughtItems
v:Destroy()
end
end
end
end
end)
结束
【问题讨论】: