Advertisement
Previized

Spider-Man Physics [ROBLOX]

Jul 8th, 2017
17,259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.95 KB | None | 0 0
  1. --@author FiredDusk (aka Previized)
  2.  
  3. --[[ NOTE: (READ)
  4.     (If you make this into a game with this code, PLEASE give me credit!) I love you <3
  5.     Make sure your game has FE TAKEN OFF! This is not FE compatible.   
  6.  
  7.     1. Make sure you go Configure your game and make it R15 ONLY!
  8.     2. Put this code in a LocalScript and put the LocalScript in: StarterPlayer > StarterCharacterScripts
  9.     3. Go in Workspace and change the property "FallenPartsDestroyHeight" to -3500 (if you want to)
  10.  
  11.     [CONTROLS]:
  12.     (Move Camera) - Moves you in that direction
  13.     (Left Click) - Throws Web / Removes Web
  14.     (Q) - Climb Web
  15.     (E) - Climb Down Web
  16.  
  17.     My game is here: https://www.roblox.com/games/900966148/Spider-Man-Physics
  18. --]]
  19.  
  20. --// Client
  21. local Player = game.Players.LocalPlayer
  22. local Character = Player.Character or Player.CharacterAdded:Wait()
  23. local Mouse = Player:GetMouse()
  24. local Camera = workspace.CurrentCamera
  25.  
  26. --// Services
  27. local ReplicatedStorage = game:GetService('ReplicatedStorage')
  28. local UIS = game:GetService('UserInputService')
  29. local RunService = game:GetService('RunService')
  30.  
  31. --// Main
  32. local Humanoid = Character:FindFirstChild('Humanoid')
  33. if Humanoid then
  34.     Humanoid.JumpPower = 100
  35.     Humanoid.WalkSpeed = 20
  36. end
  37.  
  38. local Clicked = false
  39. Mouse.Button1Down:Connect(function()
  40.     if Clicked == false and Mouse.Target ~= nil and Character:FindFirstChild('LeftHand') then
  41.         Clicked = true
  42.         local Pos = Mouse.Hit.p
  43.        
  44.         --// I have this commented out if you want an animation. (Might be glitchy!)
  45. --      local Anim = Instance.new('Animation',Character)
  46. --      Anim.AnimationId = 'rbxassetid://769730840'
  47. --      PlayAnim = Character:WaitForChild('Humanoid'):LoadAnimation(Anim)
  48. --      PlayAnim:Play()
  49.        
  50.         if Character:FindFirstChild('HumanoidRootPart') then
  51.             local Sound = Instance.new('Sound',Character.HumanoidRootPart)
  52.             Sound.SoundId = 'rbxassetid://231731980' -- Web sound, you may change this sound id if you want ;)
  53.             Sound:Play()
  54.         end
  55.        
  56.         Part = Instance.new('Part',workspace)
  57.         Part.Size = Vector3.new(1,1,1)
  58.         Part.Transparency = 1
  59.         Part.Anchored = true
  60.         Part.CanCollide = false
  61.         Part.CFrame = CFrame.new(Pos)
  62.        
  63.         local Att0 = Instance.new('Attachment',Player.Character.LeftHand)
  64.         local Att1 = Instance.new('Attachment',Part)
  65.        
  66.         Rope = Instance.new('RopeConstraint',Player.Character.LeftHand)
  67.         Rope.Color = BrickColor.new('Institutional white')
  68.         Rope.Visible = true
  69.         Rope.Length = (Player.Character.LeftHand.Position - Part.Position).magnitude
  70.         Rope.Attachment0 = Att0
  71.         Rope.Attachment1 = Att1
  72.        
  73.         --// Force
  74.         Force = Instance.new('BodyForce',Player.Character:WaitForChild('HumanoidRootPart'))
  75.         while Force ~= nil and wait() do
  76.             Force.Force = Camera.CFrame.lookVector * Vector3.new(10000,0,10000) -- Force added when you swing. You may change this.
  77.         end    
  78.     elseif Clicked == true then
  79.         Clicked = false
  80.        
  81.         if Rope then
  82.             Rope:Destroy()
  83.         end
  84.         if Part then
  85.             Part:Destroy()
  86.         end
  87.         if Force then
  88.             Force:Destroy()
  89.         end
  90. --      if PlayAnim then -- This stop the animation
  91. --          PlayAnim:Stop()
  92. --      end
  93.     end
  94. end)
  95.  
  96. --// Climbing Web
  97. UIS.InputBegan:Connect(function(Input)
  98.     if Input.KeyCode == Enum.KeyCode.Q then
  99.         ClimbingWeb = false
  100.         if Rope then
  101.             ClimbingWeb = true
  102.             while ClimbingWeb and Rope do
  103.                 Rope.Length = Rope.Length - 3 -- Basically, the higher the number, the faster it pulls you.
  104.                 RunService.RenderStepped:Wait()
  105.             end
  106.         end
  107.     end
  108. end)
  109.  
  110. UIS.InputEnded:Connect(function(Input)
  111.     if Input.KeyCode == Enum.KeyCode.Q then
  112.         ClimbingWeb = false
  113.     end
  114. end)
  115.  
  116. --// ReleaseWeb
  117. UIS.InputBegan:Connect(function(Input)
  118.     if Input.KeyCode == Enum.KeyCode.E then
  119.         ReleaseWeb = false
  120.         if Rope then
  121.             ReleaseWeb = true
  122.             while ReleaseWeb and Rope do
  123.                 Rope.Length = Rope.Length + 3 -- Same here, this is for going down though.
  124.                 RunService.RenderStepped:Wait()
  125.             end
  126.         end
  127.     end
  128. end)
  129.  
  130. UIS.InputEnded:Connect(function(Input)
  131.     if Input.KeyCode == Enum.KeyCode.E then
  132.         ReleaseWeb = false
  133.     end
  134. end)
  135.  
  136. -- HI :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement