I'm trying to work on scripting a save stats feature, and I want the players' stats to save when their stats change. The only problem is that I don't know how to use "Player" when in a connection line of a regular script, not Local Script. Here's the save script, if you need the code:
function saveStats(Player)
repeat wait() until Player
--gold and gems save
Player:SaveNumber(goldKey, Player.leaderstats.Gold.Value)
Player:SaveNumber(gemsKey, Player.leaderstats.Gems.Value)
--level and xp save
Player:SaveNumber(levelKey, Player.leaderstats.Level.Value)
Player:SaveNumber(xpKey, Player.Exp.Value)
end
How would a connection line work? Also, if you can find a way to make this in a LocalScript feel free, just nothing has been working for me in LocalScripts.

2 comments
I want it so that when the stats are changed, it runs the function, like the example I made. I'm just not sure how to connect it to the player.
Sorry, I missed that -- my post now addresses that