Help with a jumping script

im confused, so this script its supposed to change ur speed to 70 when jumping then to 30 when u down that works, but when the speed boost doesnt work

local UserInputService = game:GetService(“UserInputService”)
local Player = game.Players.LocalPlayer
UserInputService.InputBegan:Connect(function(input)
local speed = Player.Character.Speed

if input.KeyCode == Enum.KeyCode.Space then
if speed.Value == false then
if Player.Character.Humanoid.WalkSpeed == 70 then

  		Player.Character.Humanoid.WalkSpeed = 30
  	else
  		Player.Character.Humanoid.WalkSpeed = 70
  	end
  else
  	if Player.Character.Humanoid.WalkSpeed == 70 then

  		Player.Character.Humanoid.WalkSpeed = 50
  	else
  		Player.Character.Humanoid.WalkSpeed = 70
  	end
  end

end
end)

local UserInputService = game:GetService(“UserInputService”)
local Player = game.Players.LocalPlayer

UserInputService.InputBegan:Connect(function(input)
	local speed = Player.Character.Speed
	if input.KeyCode == Enum.KeyCode.Space then
		if speed.Value == false then
			if Player.Character.Humanoid.WalkSpeed == 70 then
				Player.Character.Humanoid.WalkSpeed = 30
			else
				Player.Character.Humanoid.WalkSpeed = 70
			end
		else
			if Player.Character.Humanoid.WalkSpeed == 70 then
				Player.Character.Humanoid.WalkSpeed = 50
			else
				Player.Character.Humanoid.WalkSpeed = 70
			end
		end
	end
end)

I took the liberty to clean up your code a bit. The indentation that you has was strange and made it hard to read. So, what’s broken? Where is Player.Character.Speed.Value being set at? The way that I see it, depending on if Speed.Value is true or false determines how fast the character moves after being at a speed of 70 studs/sec.

The problem with this is that the script will only run once per hit of the space bar. Have you considered using the humanoid state event? If it’s jumping then you change the speed to 70. If it’s anything else, change it to 50 or 30 based on what Speed.Value is. It takes a little bit more code to use, but it should solve the problem.

local human = Player.Character:WaitForChild("Humanoid", 10)

human.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Jumping then
		human.WalkSpeed = 70
	else
		if Player.Character.Speed.Value == true then
			human.WalkSpeed = 50
		else
			human.WalkSpeed = 30
		end
	end
end)

didnt work or im too dumb idk .

Hmm… That should have worked. What did it do or didn’t do?

user input service can only be used in local scripts so your gonna need to detect it on a local script, then use a remote event to go to the server side to change your walkspeed

I’ve tested it. You can change Humanoid.WalkSpeed on the client and it will work. The problem is it won’t replicate to the server, so any anti-cheating code may flag it. However, you don’t want to just allow the remote event to set the walk speed for a character on the server because that opens up a security issue that an exploiter can take advantage of.