I need help with mobile jump keycode (not fixed yet please help) very needed

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to add to this script to make it so it does’nt just work with console and computer. But with mobile aswell.
  2. What is the issue? Include screenshots / videos if possible!
    I am unsure on how to fix this script.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked for solutions but couldnt find anything that matched.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    its a double jump script.
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local uis = game:GetService("UserInputService")

local canDoubleJump = false
local hasLanded = true


humanoid.StateChanged:Connect(function(previous, new)
	if game.ReplicatedStorage.PurchasedDoubleJump.Value == true then

	if new == Enum.HumanoidStateType.Jumping and hasLanded then
		
		if not canDoubleJump then canDoubleJump = true; hasLanded = false end
		
		
	elseif new == Enum.HumanoidStateType.Landed then
		
		canDoubleJump = false
		hasLanded = true
		end
		end
end)

uis.InputBegan:Connect(function(input, processed)
	if game.ReplicatedStorage.PurchasedDoubleJump.Value == true then
			if processed then return end
	
		if input.KeyCode == Enum.KeyCode.Space or input.KeyCode == Enum.KeyCode.ButtonA then --need mobile keycode here
		
		if canDoubleJump then
			
			humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			canDoubleJump = false
	end

		end	
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I put a note to were I need it.

Please help please please I really need this

UserInputService has a JumpRequest connection that will work on all platforms.

Example script:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local uis = game:GetService("UserInputService")

local canDoubleJump = false
local hasLanded = true


humanoid.StateChanged:Connect(function(previous, new)
	if game.ReplicatedStorage.PurchasedDoubleJump.Value == true then

		if new == Enum.HumanoidStateType.Jumping and hasLanded then

			if not canDoubleJump then canDoubleJump = true; hasLanded = false end


		elseif new == Enum.HumanoidStateType.Landed then

			canDoubleJump = false
			hasLanded = true
		end
	end
end)

uis.JumpRequest:Connect(function()
	
	if game.ReplicatedStorage.PurchasedDoubleJump.Value == true then
		
		if canDoubleJump then
			
			humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			canDoubleJump = false
		end
	end
end)

Hope this helps,
Fizzitix

Do I just replace my entire script with this?

It was buggy and didn’t work I jump but can’t double jump

Hi! I believe that JumpRequest can help you. JumpRequest will work on all devices including mobile, console, VR, and computer.

uis.JumpRequest:Connect(function()
 -- your function here
end)

Have a good time,
Clocky

Can you rewrite my script just change the stuff to that because I am very confused

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local uis = game:GetService("UserInputService")

local canDoubleJump = false
local hasLanded = true

uis.JumpRequest:Connect(function(input, processed)
	if game.ReplicatedStorage.PurchasedDoubleJump.Value == true then
			if processed then return end
		
		if canDoubleJump then
			
			humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			canDoubleJump = false
	end

		end	
	end
end)

Hope this will help you. If it was useful choose this as a solution please.

Have a good time,
Clocky

JumpRequest doesn’t return input or processed, that might throw an error. Consider editing your script.

I think that is because of

When the player jumps, their state changes to Jumping. You can’t change a state to something it already is.

You would probably have to work something else out, like using a BodyForce or something. I’m sure there are YouTube tutorials out there
that can help you out with that.