You can write your topic however you want, but you need to answer these questions:
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.
What is the issue? Include screenshots / videos if possible!
I am unsure on how to fix this script.
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.
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)
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.
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.