I have been struggling with changing the walkspeed of a players humanoid upon them respawning after dying, i get no errors while testing - I am using RemoteEvent, i am not sure if that is neccesary
LocalScript is in the StarterCharacterScripts folder
-- LocalScript local plr = game.Players.LocalPlayer local char = script.Parent local hum = char:WaitForChild("Humanoid") local humroot = char:WaitForChild("HumanoidRootPart") local function onDeath() game.ReplicatedStorage.AddStats:FireServer() end hum.Died:Connect(onDeath) -- Script game.ReplicatedStorage.AddStats.OnServerEvent:Connect(function(plr) local char = plr.Character local hum = char:WaitForChild("Humanoid") local gui = plr.PlayerGui:WaitForChild("ValueGui") local textLabel = gui.JumpValue local walkSpeed = hum.WalkSpeed local jumpPower = hum.JumpPower print("Stats saved!") plr.CharacterAdded:Connect(function() print("character respawned") char:WaitForChild("Humanoid").WalkSpeed = walkSpeed hum.JumpPower = jumpPower end) end)
Walking speed does not need Remote Events, you can use humanoid.WalkSpeed to change a humanoid's speed.
hum.WalkSpeed = 0
Edit: If you place a folder in a player with 2 intvalues that change their values as the humanoid changes its jumppower or walkspeed, then whenever a player respawns their character you can change their jumppower and walkspeed to those values. This will now only not work on the client side, so you have to change jumppower and walkspeed on the server side. If jumppower doesn't work, make sure your humanoids are using jumppower and not jumpheight.
Script creating two intvalues inside players as they join:
local Players = game:GetService("Players") local StarterPlayer = game:GetService("StarterPlayer") local function PlayerAdded(Player) local Folder = Instance.new("Folder") Folder.Name = "PlayerData" Folder.Parent = Player local IntValue1 = Instance.new("IntValue") IntValue1.Name = "JumpPower" IntValue1.Parent = Folder IntValue1.Value = StarterPlayer.CharacterJumpPower local IntValue2 = Instance.new("IntValue") IntValue2.Name = "WalkSpeed" IntValue2.Parent = Folder IntValue2.Value = StarterPlayer.CharacterWalkSpeed local function CharacterAdded(Character) local Humanoid = Character:WaitForChild("Humanoid") Humanoid.JumpPower = IntValue1.Value Humanoid.WalkSpeed = IntValue2.Value local function JumpPowerChanged() IntValue1.Value = Humanoid.JumpPower end Humanoid:GetPropertyChangedSignal("JumpPower"):Connect(JumpPowerChanged) local function WalkSpeedChanged() IntValue2.Value = Humanoid.WalkSpeed end Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(WalkSpeedChanged) end Player.CharacterAdded:Connect(CharacterAdded) end Players.PlayerAdded:Connect(PlayerAdded)
Make sure to put this script in Game.ServerScriptService or Game.Workspace, as a server script of course.
Please let me know if my editing didn't help, I'll be happy to help.