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

How To Save Humanoid WalkSpeed After Death?

Im Making About the Game About Stats, And One of Stats is walkspeed, All i have to do is when a Humanoid Died, The WalkSpeed Goes Back to 16, How can i prevent reseting the walkspeed on spawn?

1 answer

I'd have the WalkSpeed of the player stored in a Folder or wherever you want as an IntValue with the IntValue.Name as the players name and Its Value as the desired default WalkSpeed. It gets changed when the player dies if the players walkspeed has been changed.

You can do that or use a table to store player data for each player within the script. I choose a Folder for this example since It's easier to understand.

--In a regular Script
game:GetService('Players').PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
    	character:WaitForChild("Humanoid").WalkSpeed = game.Workspace.Folder:FindFirstChild(player.Name).Value
		character:WaitForChild("Humanoid").Died:Connect(function()
			game.Workspace.Folder:FindFirstChild(player.Name).Value = character.Humanoid.WalkSpeed
		end)
	end)
end)

3 comments

0

Where can i put the script?, whats the parent of the script?

0

The parent of this script will be Workspace. Remember to create that Folder inside Workspace too and create an IntValue with your username and the Value as the WalkSpeed you want.

0

Sorry i think you misunderstand, what i mean all the players in the server, not only the player that is name on int value, But still, Thanks For The Effort

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