Answered by
6 years ago Edited 6 years ago
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.
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | local GiverMaxOutput = |
03 | local CurrentBalance = 0 |
05 | (variable you used for money here).Changed:Connect( function () |
06 | if money.Value > CurrentBalance + GiverMaxOutput |
09 | CurrentBalance = (variable for money).Value |
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.
12 | script.Parent.Touched:Connect( function (hit) |
14 | if hit:FindFirstChild( "Worth" ) and CashToCollect.Value ~ = MaxGiverOutput then |
15 | if CashToCollect.Value + hit.Worth.Value = < MaxGiverOutput then |
17 | CashToCollect.Value = CashToCollect.Value + hit.Worth.Value |
-Cmgtotalyawesome