StatsService, module for creating easy Stats

I’ve been working on a module that I am looking to recieve some feedback on, I call it StatsService it handles stats such as leaderstats but also non leaderstats. Which means you can easily create leaderstats with saving included using roblox datastores.

Heres an example below, it creates 3 stats inside the roblox leaderstats and keeps track of them until the server closes or StatsService.save() is called. All stats can be modified inside the player’s leaderstats, or under ServerStorage.Stats_Temp[plr.UserId][key]

local StatsService = require(15983047774)


game.Players.PlayerAdded:Connect(function(plr)
	local playerBranch = StatsService.Branch(plr, true, "server") -- Player : the player, bool : if it should create a branch underneath the player's leaderboard ( true ) or under ServerStorage ( false ), string : the key of the branch.
	
	playerBranch.new("Cash","NumberValue",0) -- returns the object
	playerBranch.new("TimePlayed","IntValue",0)
	playerBranch.new("new","BoolValue",true)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	StatsService.save() -- Saves all data modified for all players.
end)

I hope to improve this further on to make this as easy to create new stats for players. Let me know what I can do to improve this module.

2 Likes