I've done this and not sure how to add a lvl to a player after 30 seconds. every 30 seconds.
local datastore = game:GetService("DataStoreService"):GetDataStore("") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue") leaderstats.Name = "leaderstats" leaderstats.Parent = player local points = Instance.new("IntValue") points.Name = "Level" points.Parent = leaderstats local key = "user-" .. player.userId local storeditems = datastore:GetAsync(key) if storeditems then points.Value = storeditems[1] else local items = {points.Value} datastore:SetAsync(key, items) end end) game.Players.PlayerRemoving:connect(function(player) local items = {player.leaderstats.Level.Value} local key = "user-" .. player.userId datastore:SetAsync(key, items) end)
make the scripts a normal/ server script put it in serverscript service. if the first script dosen't work try the 2nd one
game.Players.PlayerAdded:Connect(function(plr) local level = plr.leaderstats.Level while true do level.Value = level.Value + 1 wait(30) end end)
If the first script dosen't work
game.Players.PlayerAdded:Connect(function(plr) local level = plr.leaderstats.Level while true do level = level + 1 wait(30) end end)
Try adding lines 13 to 16
local datastore = game:GetService("DataStoreService"):GetDataStore("") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue") leaderstats.Name = "leaderstats" leaderstats.Parent = player local points = Instance.new("IntValue") points.Name = "Level" points.Parent = leaderstats while true do wait(30) points.Value = points.Value + 1 end local key = "user-" .. player.userId local storeditems = datastore:GetAsync(key) if storeditems then points.Value = storeditems[1] else local items = {points.Value} datastore:SetAsync(key, items) end end) game.Players.PlayerRemoving:connect(function(player) local items = {player.leaderstats.Level.Value} local key = "user-" .. player.userId datastore:SetAsync(key, items) end)