Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local ContextActionService = game:GetService("ContextActionService")
- local Player = Players.LocalPlayer
- local Jumping = false
- local LeftValue, RightValue = 0, 0
- local function Left(Action, Input)
- if Input == Enum.UserInputState.Begin then
- LeftValue = 1
- elseif Input == Enum.UserInputState.End then
- LeftValue = 0
- end
- end
- local function Right(Action, Input)
- if Input == Enum.UserInputState.Begin then
- RightValue = 1
- elseif Input == Enum.UserInputState.End then
- RightValue = 0
- end
- end
- local function Jump(Action, Input)
- if Input == Enum.UserInputState.Begin then
- Jumping = true
- elseif Input == Enum.UserInputState.End then
- Jumping = false
- end
- end
- local function IfMoving()
- if Player.Character and Player.Character:FindFirstChild("Humanoid") then
- if Jumping then
- Player.Character.Humanoid.Jump = true
- end
- local MoveDirection = RightValue - LeftValue
- Player.Character.Humanoid:Move(Vector3.new(MoveDirection, 0, 0), false)
- end
- end
- RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, IfMoving)
- ContextActionService:BindAction("Left", Left, true, Enum.KeyCode.A, Enum.KeyCode.Left, Enum.KeyCode.DPadLeft, Enum.KeyCode.ButtonR1)
- ContextActionService:BindAction("Right", Right, true, Enum.KeyCode.D, Enum.KeyCode.Right, Enum.KeyCode.DPadRight, Enum.KeyCode.ButtonR2)
- ContextActionService:BindAction("Jump", Jump, true, Enum.KeyCode.W, Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement