How to change the player's walkspeed through a script?

Have you tried adding the player character first before using the plr parameter?

1 Like

I’m trying to use remote events now:

local rep = game:GetService("ReplicatedStorage")
local SpinnerWalkSpeed = rep.WalkSpeedEvents:WaitForChild("SpinnerWalkSpeer")
local DefWalkSpeed = rep.WalkSpeedEvents:WaitForChild("DefWalkSpeed")

SpinnerWalkSpeed.OnClientEvent:Connect(function()
	local player = game.Players.LocalPlayer
	local char = player.CharacterAdded:wait()
	local h = char.Humanoid

	h.WalkSpeed = 0
	h.JumpPower = 80
end)

DefWalkSpeed.OnClientEvent:Connect(function()
	local player = game.Players.LocalPlayer
	local char = player.CharacterAdded:wait()
	local h = char.Humanoid

	h.WalkSpeed = 16
	h.JumpPower = 50
end)

But this isn’t working either…
Please help

Please elaborate further, thanks! :slight_smile:

local function SpinnerWalkSpeed(plr)
	local humanoid = plr.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.WalkSpeed = 0
		humanoid.JumpPower = 80
	end
end

local function DefaultWalkSpeed(plr)
	local humanoid = plr.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.WalkSpeed = 16
		humanoid.JumpPower = 50
	end
end

In the script shown above, how are you passing the arguments through to the functions?

What are you passing as “plr”? The actual player, or the player’s character?

Has anyone solved this post yet? Because i think I know something that might work

I already got the script working. Just waiting for his response.

1 Like

Ah I see now, same thing I was going to say, nice work

Oops okay! than i will delete before he is stressing out :smiley:

Sorry for the wait! Been busy.
This doesn’t seem to be working… The character’s walkSpeed is not changing. There is nothing in the output. ( it is also not printing.)

I also tried yours, it also doesn’t do anything. And there’s nothing in the output

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(Character)
		
		local Humanoid = Character:WaitForChild("Humanoid")
		
		function SpinnerWalkSpeed()
			Humanoid.WalkSpeed = 0
			if Humanoid.UseJumpPower == true then
				Humanoid.JumpPower = 80
			else
				Humanoid.JumpHeight = 25
			end
			print("SpinnerSpeed")
		end
		
		function DefaultWalkSpeed()
			Humanoid.WalkSpeed = 16
			if Humanoid.UseJumpPower == true then
				Humanoid.JumpPower = 50
			else
				Humanoid.JumpHeight = 7.2
			end
			print("DefaultSpeed")
		end
		
		--What is happening here?
		SpinnerWalkSpeed()
		DefaultWalkSpeed()
		
	end)
end)

Is this in Server Script service?

Where are you putting this script in? I tried this script on ServerScriptStorage and it works on my end. This was added onto a separate script by itself btw.

It’s a normal script in ServerScriptService.

Did you try out my script? SubToSte left out the players service which can back fire sometimes

I also tried this, It’s not working either…

Here’s the full script.

REMOVED TO PREVENT CODE BEING STOLEN

Please ignore my messy scripting.

Can you send a picture of this script in the sidebar? of the game settings/ Game tab/ Explorer
Because why are you calling server Script service in a server script?

image


is this line in use?

if you’re doing this after the players’ character is added it won’t work…
Please just make a loop that loops through all players in-game, and changes their walk speed.