Answered by
6 years ago Edited 6 years ago
The problem is probally that you are setting the XP and Rank to a saved value, when there most likely is none, try this, might be something else
001 | local dataStores = game:GetService( "DataStoreService" ) |
002 | local ds 1 = dataStores:GetDataStore( "CashDataStore" ) |
003 | local ds 2 = dataStores:GetDataStore( "LevelDataStore" ) |
004 | local ds 3 = dataStores:GetDataStore( "RankDataStore" ) |
005 | local ds 4 = dataStores:GetDataStore( "Total XP" ) |
008 | local defaultLevel = 1 |
009 | local defaultRank = "InK" |
020 | game.Players.PlayerAdded:Connect( function (player) |
022 | playersLeft = playersLeft + 1 |
024 | local leaderstats = Instance.new( "Folder" ) |
025 | leaderstats.Name = "leaderstats" |
026 | leaderstats.Parent = player |
028 | local Cash = Instance.new( "IntValue" ) |
031 | Cash.Parent = leaderstats |
033 | local Level = Instance.new( "IntValue" ) |
036 | Level.Parent = leaderstats |
038 | local Rank = Instance.new( "StringValue" ) |
040 | Rank.Value = "Innocent Killer" |
041 | Rank.Parent = leaderstats |
043 | local XP = Instance.new( "IntValue" ) |
046 | XP.Parent = leaderstats |
051 | player.CharacterAdded:Connect( function (character) |
053 | character.Humanoid.Died:Connect( function (character) |
056 | if character.Humanoid and character.Humanoid:FindFistChild( "creator" ) then |
057 | game.ReplicatedStorage.Status.Value = tostring (character.Humanoid.creator.Value).. " KILLED " ..player.Name |
059 | if character:FindFirstChild( "GameTag" ) then |
060 | character.GameTag:Destroy() |
063 | player.LoadCharacter() |
083 | player_data = ds 1 :GetAsync(player.UserId.. "-Cash" ) or defaultCash |
084 | player_data 2 = ds 2 :GetAsync(player.UserId.. "-Level" ) or defaultLevel |
085 | player_data 3 = ds 3 :GetAsync(player.UserId.. "-Rank" ) or defaultRank |
086 | player_data 4 = ds 4 :GetAsync(player.UserId.. "-XP" ) or DefaultXP |
089 | if player_data ~ = nil then |
091 | Cash.Value = player_data |
094 | Cash.Value = defaultCash |
097 | if player_data 2 ~ = nil then |
098 | Level.Value = player_data 2 |
100 | Level.Value = defaultLevel |
103 | if player_data 3 ~ = nil then |
104 | Rank.Value = player_data 3 |
106 | Rank.Value = defaultRank |
109 | if player_data 4 ~ = nil then |
110 | XP.Value = player_data 4 |
117 | local bindableEvent = Instance.new( "BindableEvent" ) |
119 | game.Players.PlayerRemoving:Connect( function (player) |
122 | ds 1 :SetAsync(player.UserId.. "-Cash" , player.leaderstats.Cash.Value) |
123 | ds 2 :SetAsync(player.UserId.. "-Level" , player.leaderstats.Level.Value) |
124 | ds 3 :SetAsync(player.UserId.. "-Rank" , player.leaderstats.Rank.Value) |
125 | ds 4 :SetAsync(player.UserId.. "-XP" , player.leaderstats.XP.Value) |
126 | print ( 'All ds saved' ) |
127 | playersLeft = playersLeft - 1 |
133 | game:BindToClose( function () |
135 | while playersLeft > 0 do |
136 | bindableEvent.Event:Wait() |
Hopes this helps