Advertisement
Previized

LocalScript ("Physics")

Nov 14th, 2020 (edited)
3,051
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.30 KB | None | 0 0
  1. --@author FiredDusk (aka Previized)
  2.  
  3. --[[ NOTE:
  4.     1. Make sure you go Configure your game and make it R15 ONLY!
  5.     2. Put this code in a LocalScript and put the LocalScript: StarterPlayer > StarterCharacterScripts
  6.     3. Go in Workspace and change the property "FallenPartsDestroyHeight" to -3000 (if needed)
  7. --]]
  8.  
  9. --// Client
  10. local Player = game.Players.LocalPlayer
  11. local Character = Player.Character or Player.CharacterAdded:Wait()
  12. local Mouse = Player:GetMouse()
  13. local Camera = workspace.CurrentCamera
  14.  
  15. --// Services
  16. local ReplicatedStorage = game:GetService('ReplicatedStorage')
  17. local UIS = game:GetService('UserInputService')
  18. local RunService = game:GetService('RunService')
  19.  
  20. --// Remotes
  21. local ShootWeb = game.ReplicatedStorage:WaitForChild('ShootWeb')
  22. local RemoveWeb = game.ReplicatedStorage:WaitForChild('RemoveWeb')
  23. local ClimbUpWeb = game.ReplicatedStorage:WaitForChild('ClimbUpWeb')
  24. local ClimbDownWeb = game.ReplicatedStorage:WaitForChild('ClimbDownWeb')
  25. local AddForce = game.ReplicatedStorage:WaitForChild('AddForce')
  26.  
  27. --// Main
  28. local BodyForce = Instance.new('BodyForce',Player.Character:WaitForChild('HumanoidRootPart'))
  29.  
  30. local Clicked = false
  31. local CanClick = true
  32. local AddingForce = false
  33.  
  34. Mouse.Button1Down:Connect(function()
  35.     if Clicked == false and Mouse.Target ~= nil and Character:FindFirstChild('LeftHand') and CanClick == true then
  36.         Clicked = true
  37.         CanClick = false
  38.         local Pos = Mouse.Hit.p
  39.         AddingForce = true
  40.  
  41.  
  42.         local Request = 'ShootWeb'
  43.         ShootWeb:FireServer(Request,Pos)
  44.  
  45.         spawn(function()
  46.             while AddingForce == true do
  47.                 wait(.01)
  48.                 BodyForce.Force = (Camera.CFrame.lookVector * Vector3.new(10000,0,10000))
  49.                 if AddingForce == false then
  50.                     BodyForce.Force = (Camera.CFrame.lookVector * Vector3.new(1000,0,1000))
  51.                 end
  52.             end
  53.         end)
  54.  
  55.         wait(.5)
  56.         CanClick = true
  57.     elseif Clicked == true and CanClick then
  58.         CanClick = false
  59.         Clicked = false
  60.  
  61.         AddingForce = false
  62.         local Request = 'RemoveWeb'
  63.         RemoveWeb:FireServer(Request)
  64.  
  65.         wait(.5)
  66.         CanClick = true
  67.  
  68.     end
  69. end)
  70.  
  71.  
  72. --// Climbing Web
  73. local ClimbingWeb = false
  74. UIS.InputBegan:Connect(function(Input)
  75.     if Input.KeyCode == Enum.KeyCode.Q then
  76.  
  77.         local LeftHand = Character:FindFirstChild('LeftHand')
  78.         if LeftHand then
  79.             if LeftHand:FindFirstChild('RopeConstraint') then
  80.                 ClimbingWeb = true
  81.                 while ClimbingWeb == true and LeftHand:FindFirstChild('RopeConstraint') do
  82.                     LeftHand.RopeConstraint.Length = LeftHand.RopeConstraint.Length - 3
  83.                     game:GetService('RunService').Heartbeat:Wait()
  84.                 end
  85.             end
  86.         end
  87.     end
  88. end)
  89.  
  90. UIS.InputEnded:Connect(function(Input)
  91.     if Input.KeyCode == Enum.KeyCode.Q then
  92.         ClimbingWeb = false
  93.  
  94.     end
  95. end)
  96.  
  97. --// ReleaseWeb
  98. UIS.InputBegan:Connect(function(Input)
  99.     if Input.KeyCode == Enum.KeyCode.E then
  100.         ClimbingWeb = true
  101.  
  102.         local LeftHand = Character:FindFirstChild('LeftHand')
  103.         if LeftHand then
  104.             if LeftHand:FindFirstChild('RopeConstraint') then
  105.                 ClimbingWeb = true
  106.                 while ClimbingWeb == true and LeftHand:FindFirstChild('RopeConstraint') do
  107.                     LeftHand.RopeConstraint.Length = LeftHand.RopeConstraint.Length + 3
  108.                     game:GetService('RunService').Heartbeat:Wait()
  109.                 end
  110.             end
  111.         end
  112.     end
  113. end)
  114.  
  115. UIS.InputEnded:Connect(function(Input)
  116.     if Input.KeyCode == Enum.KeyCode.E then
  117.         ClimbingWeb = false
  118.     end
  119. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement