Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm Stuck, I Don't Know How To Save Data!?

I've been trying to save my Data using DataStores but I'm not sure where to start?

Leaderstats

local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("KillsDataSaver")


game.Players.PlayerAdded:Connect(function(plr)
	
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = plr
	
	local kills = Instance.new("IntValue")
	kills.Name = "Kills"	
	kills.Parent = stats
	
	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	deaths.Parent = stats	
	
	local gems = Instance.new("IntValue")
	gems.Name = "Gems"
	gems.Parent = stats	
	
	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Parent = stats	
	
	plr.CharacterAdded:connect(function(char)
		
		local humanoid
		
		repeat
			humanoid = char:FindFirstChild("Humanoid")
			wait()
		until humanoid
		
		humanoid.Died:connect(function()
			
			deaths.Value = deaths.Value + 1
			
			local tag = humanoid:FindFirstChild("creator")
			
			if tag then
				
				local killer = tag.Value
				
				if killer then
					
					killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
				end
			end
		end)
	end)
	
end)

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.