【发布时间】:2022-11-05 10:01:42
【问题描述】:
我开始使用 Lua 制作游戏,并且正在尝试制作排行榜系统。但是我尝试使用 3 种编码类似结果的方法,但它没有运行,说 “输入:1:尝试索引零值(全局'游戏')”这些事件都不是我的
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = instance.new("Folder,player")
leaderstats.Name = "leaderstats"
local Points = instance.new("IntValue,leaderstats")
points.Name = "Points"
local XP = instance.new("IntValue,leaderstats")
xp.Name = "XP"
end)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new ("IntValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
end)
local players = game:GetService('Players')
players.PlayerAdded:Connect(function(player)
if player then
local folder = Instance.new('Folder')
folder.Name = "leaderstats"
folder.Parent = player
local gold = Instance.new('IntValue')
gold.Name = "Gold"
gold.Parent = folder
gold.value = 125
end
end)
所有这些事件都应该在 roblox gui 中创建排行榜,因为它发生在我从中获得它们的创建者身上。但是,当我测试运行游戏时,什么也没有发生,当我把它放在 Lua:demo 中时,它显示:“input:1:尝试索引一个 nil 值(全局'游戏')”
任何帮助将非常感激。
【问题讨论】: