Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This Datastore won't save I'm getting really frustrated! Please help me!
- local DS = game:GetService("DataStoreService"):GetDataStore("Levelz")
- local StatFile = game:GetService("ServerStorage"):WaitForChild("StatFile")
- game.Players.PlayerAdded:connect(function(player)
- local Key = "Player-"..player.userId
- local playerfolder = Instance.new("Folder", StatFile)
- playerfolder.Name = player.Name
- local strength = Instance.new("IntValue", playerfolder)
- strength.Name = "Strength"
- local defense = Instance.new("IntValue",playerfolder)
- defense.Name = "Defense"
- local sword = Instance.new("IntValue", playerfolder)
- sword.Name = "Sword"
- local slevel = Instance.new("IntValue", playerfolder)
- slevel.Name = "SLevel"
- local health = Instance.new("IntValue", playerfolder)
- health.Name = "Health"
- if DS:GetAsync(Key) then
- defense.Value = DS:GetAsync(Key)
- strength.Value = DS:GetAsync(Key)
- sword.Value = DS:GetAsync(Key)
- health.Value = DS:GetAsync(Key)
- slevel.Value = DS:GetAsync(Key)
- end
- end)
- game.Players.PlayerRemoving:connect(function(player)
- local Key = "Player-"..player.userId
- local AllStats = game.ServerStorage.StatFile[player.Name]:GetChildren()
- for i = 1, #AllStats do
- DS:SetAsync(Key,AllStats[i].Value, AllStats[i].Name)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement