【发布时间】:2020-01-08 16:15:56
【问题描述】:
我正在尝试在 Roblox 中创建命令参数。例如,/kill playername。问题是我不知道如何从字符串/kill playername 中解析玩家名。这段代码是这样的:
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if string.sub(1, #Message) == "/kill " then
--this means the string starts with /kill and is expecting an argument.
--How can I parse this argument from the string
end
end)
end)
编辑:我想添加/setdata <Playername> <DataToChange eg. money> <Value>
示例命令:
/setdata MyRobloxUsername Money 10000
我正在尝试使用类似的东西来这样做
local Command, Playername, DataToChange, Value = string.match(???)
我只需要将字符串中的值转换为变量。我可以自己弄清楚如何使用变量来更改数据。只是如何从字符串中获取值。我该怎么做?
我不接受这个答案,因为我需要进一步的帮助。一旦我得到这个帮助,我会重新接受它。我的下一个请求是类似的,但使用 3 个参数而不是 1 个。我需要帮助,因为 string:Match() 对我来说非常反直觉
【问题讨论】: