Mobile jump button disappears if Humanoid.JumpPower = 0

I have a script that puts a jump cooldown/disables being able to hold the jump button. This works fine on PC but I’ve run into a problem where the mobile jump button disappears once the Humanoid.JumpPower = 0, and doesn’t come back once its back at its regular value.

canjump = 10
runservice.RenderStepped:Connect(function()
	canjump = math.clamp(canjump-1,0,10))
end)


local uis = game:GetService("UserInputService")
humanoid.UseJumpPower = true

uis.JumpRequest:Connect(function()
	if canjump == 0 then
		humanoid.JumpPower = 40
	else
		humanoid.JumpPower = 0
	end
	canjump = 10
end)

Mobile:


PC:

I believe this is intended feature. What you can do is inside the RenderStepped, check if canjump is 0 and set the jump power to 40.

One fix could be to assign an infinitesimal to the ‘JumpPower’ property, i.e; 0.0001 (or lower if necessary). The other option would be to fork the mobile jump button itself.

Seems like a bug, i feel like the button should come back if you can actually jump. You could file a bug report, or alternatively, dont use mobile

Setting your jump power or jump height to zero removes the jump button, and comes back once it changes. In the code, jumping sets your JumpPower to zero but never sets it back to 40. You can only set the JumpPower back to 40 if the player attempts to jump, but since you can’t actually attempt a jump (due to the button not visible), it’s impossible.

1 Like

I found a way to make the button always visible

game:GetService("RunService").RenderStepped:Connect(function()
	game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("TouchGui"):WaitForChild("TouchControlFrame"):WaitForChild("JumpButton").Visible = true
	game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("TouchGui"):WaitForChild("TouchControlFrame"):WaitForChild("DynamicThumbstickFrame").Visible = true
end)
3 Likes

Four lines of code? Makes the jump button always stay visible? AWESOME!

1 Like

That’s bad practice, if you want to do it the right way then play test in studio on a mobile device.
Go to game.Players.LocalPlayer.PlayerScriptsin your explorer and copy the PlayerModule that is there, then end the play test and paste the player module in StarterPlayer > StarterPlayerScripts.

in PlayerModule.ControlModule.TouchJump module there is a connection that connects whenever the humanoid’s JumpPower property changes, and if its 0 then the JumpButton becomes invisible, simply delete the connection code and the button will stop dissapearing.

Hope that this helps, it’s actually very easy to do!

1 Like

I know this is an old thread, but since it was bumped back up to the top of the forum, I figured I would provide some insight for anyone who reads through this thread in the future.

For anyone with the same / a similar question to this, note that setting Humanoid.JumpPower to 0 is not the recommended way of achieving a jump cooldown / disabling the ability to jump, as mentioned on its Roblox Creator Documentation page:

Although setting this property to 0 will effectively prevent the humanoid from jumping, it’s recommended to disable jumping by disabling the Enum.HumanoidStateType.Jumping state through Humanoid:SetStateEnabled().

Recently, I came up with a solution that doesn’t require forking any of the default PlayerScripts, utilizes Humanoid:SetStateEnabled(), is compatible with multiple input types (including touch-screens), and solves the issue brought up in the original post of this thread of the jump button not re-appearing.

The post below includes complete LocalScript code for achieving that with a full explanation of how the code works:

1 Like

bro that message was from November of last year (probably) but thanks for that