Hi, I’m making my own game, and have a question, how to do a script that gives money to other player that being on the server (script should check if player is) like if Players:FindFirstChild(OtherPlrName) then, just by typing /pay OtherPlrName Amount. Can someone type a script without any things like msg, “/pay j4opd$”? It’s be helpful if you’re do it.
1 Like
So, can anyone help? I want to know answer for my question.
There’s probably multiple ways to do this but I would use string.split()
in which case it would be
local splitMessage = string.split(message, " ")
if splitMessage[1] and string.lower(splitMessage[1]) == "/pay" then
local player = Players:FindFirstChild(splitMessage[2] or "")
local amount = tonumber(splitMessage[3]) or 0
end
4 Likes
You would have to use the TextChatService and ultimately a TextChatCommand would be the instance you need in your case but there is a documentation to that and we are not here to write you entire scripts.
1 Like
Thx, I just made it with your script!
I think you’re best scripter ever!
Here’s a simplified way to do this:
local amount = message:match("/pay (%d+)")
if amount then
local amount = tonumber(amount)
end
I know, but it’s harder because of (%d+)
I think first solution is better
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.