When i destroy i blocks i gain 10 points out of 150 (10/150) when reached 150 then it will stop adding in the leaderstat, anyone know how to this? i will make a multiplayer game like that lol hope you understand what i thinking haha, here is my code i use but nothing happens lol please help thanks!
Player = game:GetService("Player").LocalPlayer money = Player.leaderstats.Money.Value while true do wait(1) if money.Value >= 150 then money.Value = 150 end end)
Hello, there were a few problems with your code. I have made some changes
game.Players.PlayerAdded:connect(function(player) -- Runs the script when player has joined the game (Before there was no trigger) local Player = player.Name -- Getting the players name money = game.Players[Player].leaderstats.Money -- Removed the .Value as it allready appears down below when changing while true do wait(1) if money.Value > 150 then -- Made it so it is only if it is greater (Just so it would not create an infinite loop) money.Value = 150 end end end)
If you need any more help with it just tell me :)
Hi!
if i where you i would just do if the property changed
Player = game:GetService("Player").LocalPlayer money = Player.leaderstats.Money.Value money:GetPropertyChangedSignal("Value"):Connect(function() -- This means everytime the property called "Value" changed it will execute the function. if money.Value >= 150 then money.Value = 150 end end)
But what you can also do is when you add the money to the player you check if the money is greater or equal than 150 if it is then just return the function.