1

如何在 roblox 上制作排行榜?

4

9 回答 9

2

需要在每个玩家中插入一个名为“leaderstats”的值,使用带有 PlayerAdded 事件的脚本。在 leaderstats 值中,您可以放置​​ IntValues - 它们的名称将显示为标题,它们的值将显示为玩家的统计信息。

要更改这些统计信息,您需要向创建 leaderstats 值的脚本添加不同的函数和/或事件。

于 2010-11-27T21:33:44.760 回答
2

脚本插入工作区,然后在代码中键入:

function Onplayerentered(player)

local leaderstats = Instance.new("IntValue")
leaderstats.Parent = player
leaderstats.Value = 0
leaderstats.Name = "leaderstats"

local stat = Instance.new("IntValue")
stat.Name = "" -- Put name here in between the quotations
stat.Value = -- Put the starting Value#

end

game:GetService("Players").ChildAdded:Connect(Onplayerentered)
于 2010-12-01T21:19:47.963 回答
0
  1. 调出 roblox 插入工具栏。
  2. 选择排行榜。
  3. 您可以自定义脚本以满足您的需求!
于 2010-12-12T19:01:46.560 回答
0

Roblox 排行榜是一个很长的脚本,幸运的是,该脚本允许我们轻松添加和删除 leaderstats。要添加排行榜,请在玩家对象内插入 IntValue,要添加统计信息,请在前导数据中插入 IntValue。

Roblox 上的大多数游戏都希望每个玩家都拥有相同的排行榜。所以大多数人使用 PlayerAdded 事件并创建排行榜

于 2014-07-01T02:51:39.277 回答
0
function Onplayererntered(player)

    local leaderstats = Instance.new("IntValue")
    leaderstats.Pareny = player
    leaderstats.Value = 0
    leaderstats.Name = "leaderboard"

    local stat = Instance.new("IntValue")
    statname = "Cash"
    stat.Value = 100

end
于 2018-02-13T15:16:51.483 回答
0

您首先必须在服务器脚本服务中创建一个脚本并将其命名为您想要的任何名称,然后将其写入脚本中(确保其正常脚本不是本地脚本)

game:GetService("Players").PlayerAdded:Connect(function() --make the function start when new player joins
    local player = game.Players.PlayerAdded --make player variable
    local leaderstats = instance.new("Folder", player) --make new folder and set it's parent to the player
    local money = instance.new("IntValue", leaderstats) --create new value for the stat and set it's parent to the leaderstats folder (you can create as many as u want)
    money.name = "Money" --make the name of the value
    money.Value = 0 --make the value's value
end)

这段代码很简单,有很多注释可以解释它我希望它有帮助。

于 2022-02-16T22:29:27.903 回答
0

ROBLOX 将排行榜定义为名为“leaderstats”并位于玩家对象中的对象。排行榜统计定义为 leaderstats 对象(Player>leaderstats>ValueObject)中的一个值对象。因此,让我们编写一个函数,为玩家创建一个带有“现金”统计数据的排行榜。

local function createLeaderboard(player)
    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
    local cash = Instance.new("IntValue", stats)
    cash.Name = "Cash"
    stats.Parent = player
end

然后我们需要完成这项工作。我们需要将此函数连接到来自“Players”对象的“PlayerAdded”事件。

local players = game:WaitForChild("Players")

players.PlayerAdded:connect(createLeaderboard)

基本上就是这样。请注意,上面直接显示的代码中的第 3 行等效于:

players.PlayerAdded:connect(function(player)
    createLeaderboard(player)
end)

整个脚本如下所示:

local players = game:WaitForChild("Players")

local function createLeaderboard(player)
    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
    local cash = Instance.new("IntValue", stats)
    cash.Name = "Cash"
    stats.Parent = player
end

players.PlayerAdded:connect(createLeaderboard)

建议将脚本放在“ServerScriptService”中。

于 2018-05-27T17:35:45.117 回答
0

将脚本插入 ServerScriptService 并粘贴以下代码:

plrEntered = function(plr)
    local ls = Instance.new('IntValue') --Leaderstats
    ls.Parent = plr
    ls.Value = 0
    ls.Name = 'leaderstats'

    local stat = Instance.new('IntValue')
    stat.Name = 'Money' -- Change to the value you want
    stat.Value = 0 -- Add the starting value
end

game:GetService'Players'.PlayerAdded(plrEntered)
于 2018-03-31T18:05:34.120 回答
-1
function stats(plr)
    local leaderstats = Instance.new("IntValue")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr
    
    local coins = Instance.new("IntValue")
    Coins.Name = "coins"
    Coins.Parent = leaderstats
end)
    
game.Players.PlayyerAdded:Connect(stats)
于 2021-08-04T09:56:55.717 回答