You can't set the player's money over that value. Use ElementData.
Code (server):
-- When this script starts set every players' 'money' elementdata to 0, if they haven't got one already.
for _, player in ipairs(getElementsByType("player")) do
if not getElementData(player, "money") then
setElementData(player, "money", 0)
end
end
-- When a player joins set the 'money' elementdata to 0.
addEventHandler("onPlayerJoin", getRootElement(), function()
setElementData(source, "money", 0)
end)
addCommandHandler("givemoney", function(thePlayer, cmd, targetName, amount)
if targetName and tonumber(amount) then
local target = getPlayerFromName(targetName)
if target then
setElementData(target, "money", getElementData(target, "money") + tonumber(amount))
outputChatBox("You gave $"..amount.." to "..targetName.."!", thePlayer, 0, 200, 0)
outputChatBox("You got $"..amount.."!", target, 0, 200, 0)
else
outputChatBox("Player not found.", thePlayer, 255, 0, 0)
end
else
outputChatBox("Usage: /givemoney [playername] [amount]", thePlayer, 255, 255, 255)
end
end)