Hi im trying to make it so that when you say "/pay amounthere" a moneybrick spawns on you. I need help with the sub.string stuff because when I tried to print the variable that changes depending on what the amount is it doesn't print.
local player = game.Players.LocalPlayer
local limit = 10
local mon = 0
local playername = game.Players.LocalPlayer.Name
local drop = game.Workspace.playername.Torso.Position
local moneybrick = game.Lighting.Money:Clone()
function PayChatted(message, player)
if string.sub(message, 1, 5) == "/pay " then
mon = string.sub(message, 6)
print(mon)
if mon < limit then print("get richer")
elseif mon > limit then
player.leaderstats.Money = player.leaderstats.Money - mon
moneybrick.money.Value = mon
moneybrick.Parent = game.Workspace
moneybrick.Position = drop
end
end
end
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message) PayChatted(message, player)
end)
end)

1 comment
i hope you found this helpful!