Hi, I am new here, and also to scripting. (Just go easy on me) so, I am making a game that has Points and Wins in Leaderstats;
game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local val = Instance.new("IntValue") val.Name = "Points" val.Value = 0 val.Parent = leaderstats local val = Instance.new("IntValue") val.Name = "Wins" val.Value = 0 val.Parent = leaderstats end)
But how do i Save my Leaderstats?
Thanks,
-kyan_BVBfan
Here's DataStore2 - In My Opinion, Better For Values
ServerScript Inside Of ServerScriptService
--// Gets DataStore2 local DataStore2 = require(1936396537) --// Sets Key For Data DataStore2.Combine("_GAME_DATA_","Points","Wins") --// You Can Change "_GAME_DATA_" To Anything And It'll Reset All Values For Every Player. To Revert Versions Just Re-Use The Same Name. --// DataStore Values local defaultWins = 0 --// If There's No DataSave, It Will Set Their Wins To 0 local defaultPoints = 0 --// If There's No DataSave, It Will Set Their Points To 0 --// Functioning Part game.Players.PlayerAdded:Connect(function(player) --// Sets Up Looks local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local wins = Instance.new("IntValue",leaderstats) wins.Name = "Wins" local points = Instance.new("IntValue",leaderstats) points.Name = "Points" --// Sets Up Data local winsStore = DataStore2("Wins",player) local pointsStore = DataStore2("Points",player) --// Functions When Data Was Changed local function updateWins(newWins) player.leaderstats.Wins.Value = newWins end local function updatePoints(newPoints) player.leaderstats.Points.Value = newPoints end --// If No Data, Get's Default Value updateWins(winsStore:Get(defaultWins)) updatePoints(pointsStore:Get(defaultPoints)) --// Updates Data If Values Changed winsStore:OnUpdate(updateWins) pointsStore:OnUpdate(updatePoints) end)
Here's More Information To Use: https://kampfkarren.github.io/Roblox/api/
If you have anymore questions, comment down below and I'll be glad to help! If this worked, let me know by taking this as the solution. If it didn't comment down below what went wrong and I'll try to fix it for you.
~killerbrenden