How do i make my WalkSpeed save after i die?

leaderstat script

local Players = game.Players
Players.PlayerAdded:Connect(function(player)
	local Folder = Instance.new("Folder", player)
	Folder.Name = "leaderstats"
	local Speed = Instance.new("IntValue", Folder)
	Speed.Name = "Walkspeed"
	local Character = player.Character or player.CharacterAdded:Wait();
	local Humanoid = Character:FindFirstChild('Humanoid');
	Speed.Value = Humanoid.WalkSpeed	
	Humanoid.Changed:Connect(function() -- listens to change and updates leaderstats
		Speed.Value = Humanoid.WalkSpeed
	end)
end)

Script that gives player +1 walkspeed every second

local Players = game.Players
Players.PlayerAdded:Connect(function(player)
	local Character = player.Character or player.CharacterAdded:Wait();
	local Humanoid = Character:FindFirstChild('Humanoid');
	while true do
		wait(1)
		Humanoid.WalkSpeed = Humanoid.WalkSpeed + 1
	end
end)
2 Likes

Try something like this:

3 Likes

the leaderstat wont update its value after i died

2 Likes

Then do the same for the other piece of code, listen for when the character is added instead of when the player is added.

2 Likes

thank you, i fixed the script.

3 Likes