首页 > 解决方案 > 如何在 Roblox 中制作一个给你积分的块

问题描述

我在一个脚本中有一个排行榜。这是我的代码:

print("Cash Leaderboard Loaded")


function onPlayerEntered(newPlayer)

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue")
    cash.Name = "Money"       --name of currency (e.g. cash, money,     resources, bucks, etc.)
    cash.Value = 50      --starting money.

    cash.Parent = stats
    stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)

我正在努力做到这一点,所以当你点击一个块时,它会给你更多的钱。该代码位于不同的脚本中。在此处输入图像描述

有谁知道如何使这项工作?

标签: roblox

解决方案


当然!

local CD = script.Parent
local Amount_To_Give = 10
CD.MouseClick:Connect(function(plr)
    plr:WaitForChild('leaderstats').Money.Value = plr:WaitForChild('leaderstats').Money.Value + Amount_To_Give
end)

推荐阅读