I have spent a few hours to figure how to make a command like /setmoney player 100 Here is how my code looks like now(Its my latest code for trying this):
admins = {" ", " ", " "}
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
for i, adminName in pairs(admins) do
if player.Name == adminName then
if message:sub(1, 10) == "/setmoney " then
local y = tonumber(message:sub(12))
local targetPlayer = game.Players:FindFirstChild(message:sub(11))
de = targetPlayer.leaderstats.Money.Value
de = y
end
end
end
end)
end)
Im able to make like /freeze, /kill, /kick, /ban etc...
But when i try to make a third message sub to my command it never works. I know why the code about doesnt work cause im trying to put a message:sub after a message:sub that doesnt have a end. In this case im trying to put a number at the 12 letter. But i dont know how long the players name will be. Im also having trouble with /kick player "reason" but i think i can figure that out if i get help with these.
Feel free to rewrite my entire code if you found a solution.
Summary: Im trying to add a third message sub to /setmoney player so i can type /setmoney player 100 100 is just an example i want to be able to set a random rumber (not math.random) XD
(sry for my bad english :3)
if you are curious heres my kick command that works (without a reason)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
for i, adminName in pairs(admins) do
if player.Name == adminName then
if message:sub(1, 6) == "/kick " then
local targetPlayer = game.Players:FindFirstChild(message:sub(7))
if targetPlayer then
targetPlayer:Kick("You've been kicked by" .. player.Name)
break
end
end
end
end
end)
end)
