roblox - 如何在 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)
推荐阅读
- regex - 如何在正则表达式中替换后立即匹配第一个字符?
- java - 从 Struts 2.2.3 迁移到 2.5
- javascript - 在 React 中的 Firefox 中聚焦后文本输入模糊
- javascript - javascript函数按钮总是显示最后一行
- android - BasicNetwork.performRequest:android 中使用 volley 的意外响应代码 500
- c# - 强制对 DataGrid 进行二级排序
- python - 与 RobotFramework 一起使用的 Python 对于 if else 与 9 和大数字的比较返回错误
- python-3.x - PIPENV 从 Raspberry pi 上的现有 pipfile.lock 安装时挂起
- javascript - jQuery在chrome扩展中选择预先存在的按钮
- python-3.x - 如何 tar 目录