Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Give cash to the player by chat command? [Solved]

Asked by 7 years ago
Edited 7 years ago

SOLVED BY MYSELF

names = {"zZGalaxySolarManZz"}

game.Players.PlayerAdded:connect(function(Player)
        for i, v in pairs(names) do
          if v == Player.Name then 
            Player.Chatted:connect(function(chatmsg)
                local amount, user = chatmsg:match('give/(%d%d?%d?%d?)%s+([%w_]+)')
                if amount ~= nil and user ~= nil then
                  for _,a in pairs(game.Players:GetChildren()) do
                    local Find = a.Name
                    local player = string.match(Find, user)
                    if player then
                      local Get = game.Players:FindFirstChild(player)
                      Get.PlayerData.Rubies.Value = Get.PlayerData.Rubies.Value + (amount)
                    end
                  end
                end
              end)
          end
        end
      end)
0
Well. I'm not going to script it for you. You will have to extract the number and player variable from the chatmsg. http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation The pattern "%S+" is useful. cabbler 1942 — 7y
0
Also, you're missing an end. :P TheeDeathCaster 2368 — 7y
0
Solved :) zZGalaxySolarManZz 49 — 7y

Answer this question