Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I make this Wall Jump/Double Jump script mobile compatible?

Asked by 5 years ago
Edited 5 years ago

I want to make it to where players on mobile can simply tap their jump button twice to double jump, but I don't know how to do that.

001wait(2)
002 
003local Players = game:GetService("Players")
004local UserInputService = game:GetService("UserInputService")
005local Player = Players.LocalPlayer
006local Character = Player.Character or Player.CharacterAdded:Wait()
007local Humanoid = Character:FindFirstChildOfClass('Humanoid')
008local Root = Character.PrimaryPart
009local root = Character.HumanoidRootPart
010local yaxis = 0
011local o = 0
012local Db = true
013local CanDouble = true
014local LatestPart = nil
015local mouse = Player:GetMouse()
View all 145 lines...

1 answer

Log in to vote
0
Answered by
compUcomp 417 Moderation Voter
5 years ago
Edited 5 years ago

Instead of using mouse.KeyDown, use ContextActionService:BindAction() with Enum.PlayerActions.CharacterJump.

01local CAS = game:GetService("ContextActionService")
02 
03CAS:BindAction("WallJump", function (name, state, input)
04    if  Humanoid:GetState() == Enum.HumanoidStateType.Freefall and Db then
05 
06    local ray = Ray.new(Root.Position, Root.CFrame.lookVector*2.5)
07    local hit = game.Workspace:FindPartOnRay(ray, Character)
08 
09    if hit then
10        if hit:IsA("BasePart") and hit.CanCollide == true then
11 
12        spawn(function()
13        Db = false
14        wait(0)
15        Db = true
View all 68 lines...

This should handle all methods of jumping on all platforms. Edit: Replace the UIS.InputBegan handler with this

0
What would this look like in the script above? I tried inserting it into it but It doesn't work. Justingamer700 114 — 5y
0
Updated answer compUcomp 417 — 5y
Ad

Answer this question