Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Save Humanoid WalkSpeed After Death?

Asked by 5 years ago

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

Log in to vote
0
Answered by
Drodex 2
5 years ago
Edited 5 years ago

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)
0
Where can i put the script?, whats the parent of the script? Minecrafter09031031 16 — 5y
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. Drodex 2 — 5y
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 Minecrafter09031031 16 — 5y
Ad

Answer this question