Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this script not work when detecting the player's jumps?

So I'm making a script that Everytime you jump, your speed increases overtime until it falls.

Problem is, it's not detecting anything or changing the speed.

char=script.Parent
humanoid=char:FindFirstChildWhichIsA("Humanoid")
falling=false

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Jumping then
		if falling==false then
			falling=true
			repeat 
				humanoid.WalkSpeed=humanoid.WalkSpeed+0.05
				wait()
			until falling==false
		end
	elseif newState == Enum.HumanoidStateType.Landed then
		if falling==true then
			falling=false
			humanoid.WalkSpeed=18
		end
	end
end)

2 comments

0

yes you do as they defined char as the parent of the script

0

mabey falling= true

1 answer

✓ Accepted answer
char=script.Parent
humanoid=char:FindFirstChildWhichIsA("Humanoid")
falling=true

game:service('RunService').Heartbeat:Connect(function()
if(falling)then
humanoid.WalkSpeed=humanoid.WalkSpeed+0.05
end
end)

humanoid:GetPropertyChangedSignal('Jump'):Connect(function()
if(not(humanoid.Jump))then
falling=false
humanoid.WalkSpeed=18
else
falling=true
end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.