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?
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
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