Advertisement
Guest User

Roblox

a guest
Apr 10th, 2020
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local ContextActionService = game:GetService("ContextActionService")
  2. local Players = game:GetService("Players")
  3.  
  4.  
  5. local player = game.Players.LocalPlayer
  6. local camera = workspace.CurrentCamera
  7. local mouse = player:GetMouse()
  8.  
  9.  
  10. local PLAYER_SPEED = -45000
  11. local FORWARD_KEY = Enum.KeyCode.w
  12.  
  13. local forwardForceVector = Vector3.new(0,0,PLAYER_SPEED)
  14.  
  15. local function onMove(actionName, inputState)
  16.     if inputState == Enum.UserInputState.Begin then
  17.         player.Character.HumanoidRootPart.VectorForce.Force = forwardForceVector
  18.     elseif inputState == Enum.UserInputState.End then
  19.         player.Character.HumanoidRootPart.VectorForce.Force = Vector3.new(0,0,0)
  20.     end
  21. end
  22.  
  23. local function onAim()
  24.    
  25.     if player.Character then
  26.         local rootPart = player.Character:FindFirstChild("HumanoidRootPart")
  27.         local mouseLocation = Vector3.new(mouse.Hit.x, rootPart.Position.Y, mouse.Hit.Z)
  28.         rootPart.CFrame = CFrame.new(rootPart.Position, mouseLocation)
  29.     end
  30. end
  31.  
  32. ContextActionService:BindAction("Aim", onAim, false, Enum.UserInputType.MouseMovement)
  33. ContextActionService:BindAction("Move", onMove, false, FORWARD_KEY)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement