I'm trying to add a leveling system for my game, but my script isn't working. The following script is what adds a value to the leaderstats for all players. (SeverScriptService)
pps = game:GetService("Players")
local lvl = game.Players.pps.leaderstats.lvl
print("Passed Check 1")
while true do
print("Lvl add started.")
wait(0.5)
lvl.Value += 1
end
The following is a store data script I found from the toolbox (Workspace)
local datastore = game:GetService("DataStoreService")
local ds2 = datastore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local lvl = Instance.new("IntValue", folder)
lvl.Name = "Level"
lvl.Value = ds2:GetAsync(plr.UserId) or 0
ds2:SetAsync(plr.UserId, lvl.Value)
lvl.Changed:connect(function()
ds2:SetAsync(plr.UserId, lvl.Value)
end)
end)
If any of y'all can clarify what I'm doing wrong then thanks!

3 comments
hehe it says pps
bruh...
talking to diyamund