In a game where you gain walkspeed throughout, how might you save the player's walkspeed when they die, then reapply it after they respawn, so it doesn't reset back to normal?
✓ ANSWER ACCEPTED
Sensing a player's walkspeed, and re-applying it after they die?
2 answers
✓ Accepted answer
In a server script:
local PlayerData = {}
game.Players.PlayerAdded:Connect(function(plr)
PlayerData[plr.Name] = {
WalkSpeed = 16 --set up table
}
--------------------
plr.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
humanoid.WalkSpeed = PlayerData[plr.Name].WalkSpeed --apply saved walkspeed
end)
--------------------
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
PlayerData[plr.Name].WalkSpeed = humanoid.WalkSpeed --record walkspeed
end)
end)
Resources
CharacterAdded
PlayerAdded
Accept and upvote if this helped!
In pseudo code it would look something like: player died --> save walkspeed in a variable player respawned --> set their walkspeed to the value of the variable we put in earlier.
I'm not gonna write you an entire script but you should use some of these for reference to construct around the pseudo code I described:
https://developer.roblox.com/api-reference/event/Humanoid/Died https://developer.roblox.com/api-reference/event/Player/CharacterAdded
1 comment
1
Then why would you post this as an answer?
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Thank you for the help! It worked!
pls upvote if it helped http://prntscr.com/m1ymvo
Is it not showing up? Weird https://puu.sh/CqfpM/3deaf74d17.png
Congrats gioni you git your upvotes!
:))