Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. -- Services
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local RunService = game:GetService("RunService")
  5. local UserInputService = game:GetService("UserInputService")
  6.  
  7. -- Variables
  8. local FrameWork = require(ReplicatedStorage:WaitForChild("ViserGameFramework", 1)) -- Requiring framework.
  9. local Player = Players.LocalPlayer
  10. local Mouse = Player:GetMouse()
  11. local Character = Player.Character or Player.CharacterAdded:Wait()
  12. local RootPart = Character:WaitForChild("HumanoidRootPart", 1)
  13. local Hum = Character:WaitForChild("Humanoid", 1)
  14. local Remotes = ReplicatedStorage:WaitForChild("Remotes", 1)
  15. local Weapons = Character:WaitForChild("Weapons", 1)
  16. local Primary = Weapons:WaitForChild("Primary", 1)
  17. local Secondary = Weapons:WaitForChild("Secondary", 1)
  18. local Camera = workspace:WaitForChild("Camera", 1)
  19. local Targ
  20. local CameraGun
  21. -- Booleans
  22. local Pressed = false
  23. local Crouching = false
  24. local canViewGun = false
  25. -- Main
  26. local Walk = FrameWork.LoadAnim(Hum, 04684551470)
  27. local Run = FrameWork.LoadAnim(Hum, 4687105406)
  28. local Idle = FrameWork.LoadAnim(Hum, 4687105932)
  29. local Crouch = FrameWork.LoadAnim(Hum, 4687132323)
  30. local CrouchWalk = FrameWork.LoadAnim(Hum, 4687104903)
  31. local HoldGun = FrameWork.LoadAnim(Hum, 04741271400)
  32. local HoldMelee = FrameWork.LoadAnim(Hum, 04684554539)
  33.  
  34. -- Functions
  35. local function GiveGun()
  36. if Mouse.Target ~= nil then
  37. if Mouse.Target.Parent.Parent.Parent == workspace.Collectibles then
  38. Targ = Mouse.Target.Parent
  39. CameraGun = Targ:Clone()
  40. CameraGun.Parent = Character:WaitForChild("ViewCamera", 1)
  41. if Targ ~= nil then
  42. for i,v in pairs(Targ:GetChildren()) do
  43. if (v:IsA'BasePart') then
  44. v.Anchored = false
  45. end
  46. end
  47. CameraGun.Handle.CFrame = Camera.CFrame * CFrame.new(1.5, -1, -3)
  48. end
  49. if (RootPart.Position - Targ.Handle.Position).Magnitude <= 30 then
  50. print(Targ.Name)
  51. if Pressed then
  52. Remotes.GrabWeapon:FireServer(Targ, Targ.Parent.Name)
  53. canViewGun = true
  54. print("Success!")
  55. end
  56. end
  57. end
  58. end
  59. wait(1)
  60. Pressed = false
  61. end
  62.  
  63. local function updateCamera()
  64. if Targ ~= nil and canViewGun == true then
  65. CameraGun.Handle.CFrame = Camera.CFrame * CFrame.new(1.5, -1, -3)
  66. end
  67. end
  68.  
  69. Player.CameraMode = Enum.CameraMode.LockFirstPerson
  70.  
  71. -- Updating Camera
  72. RunService.RenderStepped:Connect(function()
  73. updateCamera()
  74. end)
  75. -- Input
  76.  
  77. Hum.Running:Connect(function(Speed)
  78. if (Walk.IsPlaying == false and Speed > 0.5 and Crouching == false) then
  79. Run:Stop(0.2)
  80. Crouch:Stop(0.2)
  81. CrouchWalk:Stop(0.2)
  82. Idle:Stop(0.2)
  83. HoldGun:Play(0.2)
  84. Walk:Play(0.2)
  85. if (Walk.IsPlaying == true and Speed > 0.5 and Crouching == true) then
  86. Run:Stop(0.2)
  87. Idle:Stop(0.2)
  88. Walk:Stop(0.2)
  89. Crouch:Stop(0.2)
  90. HoldGun:Play(0.2)
  91. CrouchWalk:Play(0.2)
  92. end
  93. elseif (Run.IsPlaying == false and Speed > 16 and Crouching == false) then
  94. Walk:Stop(0.2)
  95. Crouch:Stop(0.2)
  96. CrouchWalk:Stop(0.2)
  97. Idle:Stop(0.2)
  98. HoldGun:Play(0.2)
  99. Run:Play(0.2)
  100. elseif (Idle.IsPlaying == false and Speed < 0.5 and Crouching == false) then
  101. Walk:Stop(0.2)
  102. Crouch:Stop(0.2)
  103. CrouchWalk:Stop(0.2)
  104. Run:Stop(0.2)
  105. HoldGun:Play(0.2)
  106. Idle:Play(0.2)
  107. if (Crouching == true and Speed > 0.5) then
  108. Walk:Stop(0.2)
  109. Run:Stop(0.2)
  110. Idle:Stop(0.2)
  111. CrouchWalk:Stop(0.2)
  112. HoldGun:Play(0.2)
  113. Crouch:Play(0.2)
  114. end
  115. end
  116. end)
  117.  
  118. UserInputService.InputBegan:Connect(function(Key, Typing)
  119. if (Key.KeyCode == Enum.KeyCode.E and Typing == false) then
  120. Pressed = true
  121. GiveGun()
  122. end
  123.  
  124. if (Key.KeyCode == Enum.KeyCode.LeftControl and Typing == false) then
  125. if Crouching == false then
  126. Crouching = true
  127. elseif Crouching == true then
  128. Crouching = false
  129. end
  130. end
  131.  
  132. if (Key.KeyCode == Enum.KeyCode.LeftShift and Typing == false) then
  133. Hum.WalkSpeed = 32
  134. end
  135. end)
  136.  
  137. UserInputService.InputEnded:Connect(function(Key, Typing)
  138. if (Key.KeyCode == Enum.KeyCode.LeftShift and Typing == false) then
  139. Hum.WalkSpeed = 16
  140. end
  141. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement