How can i disable the jump button?

I’m making a game, but i have to delete the mobile button but how in the world am i’m gonna do this? I already searched, and searched, but none of them seemed to work. Can anyone help me?

6 Likes

Set player’s humanoid JumpPower to 0

1 Like

yes, but i need to delete it, so i can make a custom one, just setting the jump power won’t do anything. because if i set to like 50 again in the custom jump script, he appears again.

Edit CoreScripts. GitHub - Roblox/Core-Scripts: All of ROBLOX's core client scripts.
Or use UIS.ModalEnabled = false and you have nothing left from Jump button and joystick. :person_shrugging:

3 Likes

i appreciate the uis modal enabled, but i don’t want to disable the joystick, just the jump button, i’m gonna test the core to see if it works.

Question: where’s the jump core?

1 Like
3 Likes

Thanks, i already solved it, i just did a simple script that checks whenever it has a touch gui and some other stuff. Anyways, i did the script in starterplayer in a local script.

For those who struggling to do one jump button, here:

local Player = game.Players.LocalPlayer

repeat wait()
	
until game:IsLoaded()

if Player.PlayerGui.TouchGui then
	local TouchGui = Player.PlayerGui.TouchGui
	local TouchControlFrame = TouchGui.TouchControlFrame
	if not TouchControlFrame:FindFirstChild("JumpButton") then
		repeat wait()

		until TouchControlFrame:FindFirstChild("JumpButton")
	else
		TouchControlFrame.JumpButton:Destroy()
	end
end

Make sure to put in starter player scripts or any member of starter player in a local script.

3 Likes

I think you should use task.wait() instead of wait().

3 Likes

what’s the difference between i put just wait and task.wait? it’s the same thing, the two are the same.

1 Like

wait() is waiting MORE than need.
task.wait() is waiting LESS than wait()

Put this in a script to see a difference:

print("task.wait: ".. task.wait(1))
print("wait: ".. wait(1))
2 Likes

oooh, i see, yes, you’re right, task.wait it’s a bit more fast, while wait it increases like 2 times the value. thanks for the suggestion bro

1 Like

bruuh, it’s not working anymore :frowning:

edit: actually, sometimes it works, and sometimes it don’t? it’s really confusing

This would error if any of those objects didn’t exist at the time the script was looking for it, which might be why it only works some of the time. Making sure that those objects exist with :WaitForChild(), first, would prevent it from erroring.

Along with that, if you had any other code afterwards that was meant to run for players who aren’t on mobile, it would have never reached that point of the script because the “TouchGui” is not created unless the player is using a device with touch-screen enabled.

Here’s an example revision:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")

task.spawn(function() -- Creates a separate thread to run this code so that anything else after this function would continue running simultaneously. This makes it so that players who do not have touch-screen enabled (meaning that the "TouchGui" would never exist) would not need to wait 5 seconds for the next line of code to timeout before the rest of the script continues to run.
	
    local touchGui = PlayerGui:WaitForChild("TouchGui", 5) -- Added a timeout of 5 seconds so the code will continue and not yield forever if it doesn't find it
	if touchGui then

		local touchControlFrame = touchGui:WaitForChild("TouchControlFrame")
        if touchControlFrame then

            local jumpButton = touchControlFrame:WaitForChild("JumpButton")
            if jumpButton then
                jumpButton:Destroy()
            end

        end

	end

end)

Edit (Extra Information)

And just in case anyone finds this thread and was hoping to know how to completely disable jumping for all players (and aren’t looking to implement a custom jump button like what OP mentioned in the 3rd post), you can utilize Humanoid:SetStateEnabled(). This completely prevents players from jumping, regardless of device. For players with touch-screen enabled, the jump button is no longer shown on the screen.

Example Codeblock

-- (LocalScript Code) Place this into the StarterPlayerScripts container!
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local function OnCharacterLoad(Character)
	local Humanoid = Character:WaitForChild("Humanoid")
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end

if player.Character then
	OnCharacterLoad(player.Character)
end

player.CharacterAdded:Connect(OnCharacterLoad)

Still not what you were looking for?

If you want to disable “automatic jumping” so that the player cannot hold down the jump button and would be required to let go of the button / key before being able to jump again, I came up with a solution for that in another thread:

2 Likes

Thanks, it works now, and it works pretty like… perfectly!! Thank you so much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.