I create a tycoon. You can give me advice on how to add a player’s money check every second (that is, protection against what would be changed by some kind of script), that is, the script checks every second whether the player has any money left before. If the money exceeded to 9,999,999,999 and more, then the script immediately kicks the player from the server.
Not saying the current answer isn't going to work, but it isn't a very great idea to kick a player out for having a lot of money, what you should be checking for is if the difference in their money is above a certain number. In order for this to be logical though, you would have to cap the amount of money your giver can hold (the thing you step on to receive the money). The reason for capping the max amount is because if a player sits around awhile and then collects his money, he may get kicked out of the game, even though he did nothing wrong. The code would look like this.
game.Players.PlayerAdded:Connect(function(plr) local GiverMaxOutput = --whatever you want the giver to stop at. local CurrentBalance = 0 --make your leaderstats like before (variable you used for money here).Changed:Connect(function() if money.Value > CurrentBalance + GiverMaxOutput plr:Kick("Cheating") else CurrentBalance = (variable for money).Value end end) end)
You don't have to use this, however, it would make your game much more playable, as no one can get kicked for being on a server for a long time.
Edit:
Its clear that you probably won't use this, but in case you change your mind or realize that this way is easily better and still allows the game to be playable, I decided to add the script that caps the amount in the giver. (sorry for the run on sentence lmao). I'm going to make assumptions on how you have your system set up, but if it isn't like this it should still give you an idea.
I'm not sure if you can set a max value on an IntValue using properties as I don't have access to studio currently, but I would suggest looking through properties, as that would be the easiest way. If this fails, the script below should do it.
--[[ This script should be placed inside the collector at the end of your conveyor. ]] --// Variables \\-- MaxGiverOutput = x CashToCollect = --(locate your value inside of the giver (make sure you only define the object and not the actual value)) --// Main Script \\-- script.Parent.Touched:Connect(function(hit) --I'm assuming you have a value inside of your object at this point if hit:FindFirstChild("Worth") and CashToCollect.Value ~= MaxGiverOutput then if CashToCollect.Value + hit.Worth.Value =< MaxGiverOutput then hit:Destroy() CashToCollect.Value = CashToCollect.Value + hit.Worth.Value end end end)
-Cmgtotalyawesome
maxMoneyBeforeSuspicion = 9999999998; money = 0; --Money will increase over time from stuff, maybe the player hacking. if (money > maxMoneyBeforeSuspicion) then --Code to kick a player or give a warning or confiscate money or add to blacklist or something. end
With a setup that looks something like this, each player their own script to keep track of money and stuff.