Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Service = game:GetService("DataStoreService")
- local Dss = Service:GetDataStore("-Test data")
- local function Get_Data(Key)
- return Dss:GetAsync(Key)
- end
- local function Set_Up(Plr)
- local Stats = Instance.new("Folder")
- Stats.Name = "leaderstats"
- Stats.Parent = Plr
- local Poeng = Instance.new("IntValue")
- Poeng.Name = "Poäng"
- Poeng.Parent = Stats
- local Data = Get_Data(Plr.UserId)
- if Data ~= nil then
- warn("Got data!")
- Poeng.Value = Data["Poäng"]
- if os.time() - Data["Last Reward"] >= 100 then
- Poeng.Value = Poeng.Value + 100
- Dss:SetAsync(Plr.UserId, {
- ["Poäng"] = Poeng.Value;
- ["Last Reward"] = os.time()
- })
- end
- else
- warn("New player!")
- Dss:SetAsync(Plr.UserId, {
- ["Poäng"] = 0;
- ["Last Reward"] = os.time()
- })
- end
- end
- game.Players.PlayerAdded:Connect(function(Plr)
- Set_Up(Plr)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement