如何在 Roblox 中制作一个可以给你积分的方块

How to make a block that gives you points in 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)

我正在努力做到这一点,当你点击一个方块时,它会给你更多的钱。 该代码位于不同的脚本中。

有谁知道如何进行这项工作?

当然可以!

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)