So I was watching a tutorial on how to save data. When the video finished I tested it out and it didn't work, so I went to the output and fixed a few mistakes I had made, for example, misnaming and capitalization errors. When the output gave no error I thought it would work, but it didn't. So I looked over the script again, but I couldn't figure out what was wrong with it. Can someone help me. Thank You in Advance.
This is the script I put in the ServerScriptService. It serves as the leaderboard as well as the datasave
local dataStores = game:GetService("DataStoreService"):GetDataStore("BuckDataStore") local playerLeft = 0 game.Players.PlayerAdded:Connect(function(player) playerLeft = playerLeft + 1 local stats = Instance.new("IntValue") stats.Name = "leaderstats" stats.Parent = player local money = Instance.new("IntValue") money.Name = "ObbyBucks<|>" -- Change "Money" to anything you want to name it like "Cash" money.Value = 100 -- Change the value to how many you want when the player joins the game money.Parent = stats player.CharacterAdded:Connect(function(character) character.Humanoid.Walkspeed = 16 character.Humanoid.Died:Connect(function() if character.Humanoid and character.Humanoid:FindFirstChild('creator') then game.ReplicatedStorage.Status.Value = tostring(character.Humanoid.creator.Value.." Killed "..player.Name) end if character:FindFirstChild('GameTag') then character.GameTag:Destroy() end player:LoadCharacter() end) end) local player_data pcall(function() player_data = dataStores:GetAsync(player.UserId.."-ObbyBucks<|>") end) if player_data ~= nil then money.Value = player_data else money.Value = 100 end end) local bindableEvent = Instance.new("BindableEvent") game.Players.PlayerRemoving:Connect(function(player) pcall(function() dataStores:SetAsync(player.UserId..'-ObbyBucks<|>',player.stats.money.Value) print('Saved') playerLeft = playerLeft - 1 bindableEvent:Fire() end) end) game:BindToClose(function() while playerLeft > 0 do bindableEvent.Event:Wait() end end)