local place = game.Players.LocalPlayer.PlayerGui
function inventrans(amount)
if place.inven.InvenSee:FindFirstChild("Lava")then
place.Lava.Amount.value = place.Amount.value+amount
script.Parent.Amount = script.Parentarent.Amount-amount
else
game.ReplicatedStorage.StorageIco.Lava:clone(1).Parent =
game.Players.LocalPlayer.PlayerGui.inven.InvenSee.Lava
place.Lava.Amount.value = place.Amount.value+amount
script.Parent.Amount = script.Parentarent.Amount-amount
end
end
inventrans(23)我得到了错误Lava is not a valid member of Frame。
我正在尝试为我的游戏制作一个库存系统,但有一个错误,我不知道如何修复。请帮帮忙
发布于 2018-05-07 01:42:25
确保您的脚本是本地脚本,并且位于工具或播放器gui中。
如果不是这样,game.Players.LocalPlayer.PlayerGui将为零。
发布于 2018-07-31 14:20:20
确保您正确地找到了对象。
您应该使用:WaitForChild
示例: game.Workspace:WaitForChild("Part")
它将等待部件添加到工作区中。之所以应该使用它,是因为您的代码运行得太快,对象没有足够的时间来创建部件,因此它返回一个错误。但是如果您使用WaitForChild,它将等待对象加载,然后运行代码。
https://stackoverflow.com/questions/50200833
复制相似问题