I made this script which waits 60 seconds, then increases a leaderstat value by 1. But for some reason nothing happens to the value, and I don't get any errors on it. I feel like the answer is obvious but I have no idea how to fix it. Here's the code:
wait(1.5) function Min(NP) while true do local Stat = NP.leaderstats["Minutes Played"].Value wait(60) Stat = Stat + 1 end end game.Players.ChildAdded:Connect(Min)
I've also tried making it a StarterPlayerScripts script and the same thing happens, code below.
wait(2) while true do wait(6) script.Parent.Parent.leaderstats["Minutes Played"].Value = script.Parent.Parent.leaderstats["Minutes Played"].Value +1 end
Problem with the 1st script: You used a child added function and therefore it waits 60 seconds everytime a child is added to players. You need to find the value from the player in a different way, by using remote events, local script and a script.
Problem with the 2nd script: Most likely you did this in a local script, so you cannot change the value. Therefore use a remote event and a server script to change the value.
Hope this helps, if not feel free to ask questions.