Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Leaderstats
- game.Players.PlayerAdded:Connect(function(player)
- local s = Instance.new("Folder",player)
- s.Name = "leaderstats"
- local strength = Instance.new("IntValue",s)
- strength.Name = "Strength" -- You stat name
- end)
- -- Data Store
- local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
- game.Players.PlayerAdded:Connect(function(plr)
- wait()
- local plrkey = "id_"..plr.userId
- local save1 = plr.leaderstats.Strength -- You Stat name
- local GetSaved = ds:GetAsync(plrkey)
- if GetSaved then
- save1.Value = GetSaved[1]
- else
- local NFS = {save1.Value}
- ds:GetAsync(plrkey, NFS)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- ds:SetAsync("id_"..plr.userId, {plr.leaderstats.Strength.Value}) -- Your stat name --
- end)
- -- localscript in gui
- script.Parent.MouseButton1Click:Connect(function()
- workspace.AddStrength.Add1:FireServer()
- script.Parent.Active = false
- wait()
- script.Parent.Active = true
- end)
- -- Events Script
- script.Add1.OnServerEvent:Connect(function(player)
- player.leaderstats.Strength.Value = player.leaderstats.Strength.Value +1
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement