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

Changing WalkSpeed when Character respawned?

Asked by 3 years ago

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

01-- LocalScript
02 
03 
04local plr = game.Players.LocalPlayer
05local char = script.Parent
06local hum = char:WaitForChild("Humanoid")
07local humroot = char:WaitForChild("HumanoidRootPart")
08 
09local function onDeath()
10    game.ReplicatedStorage.AddStats:FireServer()
11end
12 
13hum.Died:Connect(onDeath)
14 
15 
View all 34 lines...

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Walking speed does not need Remote Events, you can use humanoid.WalkSpeed to change a humanoid's speed.

1hum.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:

01local Players = game:GetService("Players")
02 
03local StarterPlayer = game:GetService("StarterPlayer")
04 
05local function PlayerAdded(Player)
06 
07    local Folder = Instance.new("Folder")
08 
09    Folder.Name = "PlayerData"
10 
11    Folder.Parent = Player
12 
13    local IntValue1 = Instance.new("IntValue")
14 
15    IntValue1.Name = "JumpPower"
View all 55 lines...

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.

0
My bad, i didnt describe it well enough. The idea of the game is that your walkspeed increases every few seconds and so does your JumpPower and i want to store the players speed and jump when they die so i can give them the exact amount of speed and jump they had before they died. luxen1711 9 — 3y
0
Thank you - I just tried it and it worked. I think the solution might just have been using GetPropertyChangedSignal. luxen1711 9 — 3y
1
I'm glad it worked. Would you please accept my answer if it helped? Then others don't have to respond anymore. Bankrovers 226 — 3y
Ad

Answer this question