here is the source code pls help
local dataStores = game:GetService("DataStoreService"):GetDataStore("atomsDataStore") local deafaultCash = 25 local playersLeft = 0
game.Players.PlayerAdded:Connect(function(player)
playersLeft = playersLeft + 1
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local atoms = Instance.new("IntValue")
atoms.Name = "atoms"
atoms.Value = 0
atoms.Parent = leaderstats
local playerData = Instance.new("Folder") playerData.Name = player.Name playerData.Parent = game.ServerStorage.PlayerData
local equipped = Instance.new("StringValue") equipped.Name = "Equipped" equipped.Parent = playerData
local inventory = Instance.new("Folder") inventory.Name = "Inventory" inventory.Parent = playerData
player.CharacterAdded:connect(function(character)
character.Humanoid.WalkSpeed = 16
character.Humanoid.Died:Connect(function()
-- whenever somebody dies, the event will run
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)
--data stores
local player_data local weaponsData local equippmentData
pcall(function() player_data = dataStores:GetAsync(player.UserId.."-atoms") -- 17368234-atoms end)
pcall(function() weaponsData = dataStores:GetAsync(player.UserId.."-weps") -- 17368234-atoms end)
pcall(function() equippmentData = dataStores:GetAsync(player.UserId.."-equipped.Value") -- 17368234-atoms end)
if player_data ~= nil then -- Player has saved data, load it in atoms.Value = player_data
else -- New player atoms.Value = deafaultCash end
if weaponsData then
-- for loop through the weapons saved
-- load them in
-- set the equipped value
end
end)
local bindableEvent = Instance.new("BindableEvent")
game.Players.PlayerRemoving:Connect(function(player) pcall(function() dataStores:SetAsync(player.UserId.."-atoms",player.leaderstats.Atoms.Value) print ("Saved!") playersLeft = playersLeft - 1 bindableEvent:Fire() end)
end)
game:BindToClose(function() --this will be triggered upon shutdown while playersLeft > 0 do bindableEvent.Event:Wait() end end)
