Advertisement
Guest User

Framework V1

a guest
Jun 13th, 2020
10,543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. repeat
  2. wait()
  3. until game:IsLoaded()
  4.  
  5. local plr = game.Players.LocalPlayer
  6. local char = plr.Character
  7. local mouse = plr:GetMouse()
  8. local cam = workspace.CurrentCamera
  9.  
  10. local User = game:GetService("UserInputService")
  11. local Run = game:GetService("RunService")
  12.  
  13. local RS = game.ReplicatedStorage
  14. local GunModules = RS:WaitForChild("GunModules")
  15. local GunModels = RS:WaitForChild("GunModels")
  16.  
  17. local Primary = "AK47"
  18. local WeaponInHand
  19. local LArm, RArm
  20. local WeaponData
  21.  
  22. local aimming = false
  23.  
  24. local maincf = CFrame.new() --weapon offset of camera
  25. local larmcf = CFrame.new() --left arm offset of weapon
  26. local rarmcf = CFrame.new() --right arm offset of weapon
  27.  
  28. local aimcf = CFrame.new()
  29.  
  30. User.MouseIconEnabled = false
  31. plr.CameraMode = Enum.CameraMode.LockFirstPerson
  32.  
  33. Run.RenderStepped:Connect(function()
  34. if WeaponInHand and LArm and RArm then --Check if the weapon and arms are loaded
  35. WeaponInHand:SetPrimaryPartCFrame(
  36. cam.CFrame
  37. * maincf
  38. * aimcf
  39. )
  40.  
  41. LArm:SetPrimaryPartCFrame(
  42. WeaponInHand.PrimaryPart.CFrame
  43. * larmcf
  44. )
  45.  
  46. RArm:SetPrimaryPartCFrame(
  47. WeaponInHand.PrimaryPart.CFrame
  48. * rarmcf
  49. )
  50.  
  51. if aimming then
  52. aimcf = aimcf:Lerp(WeaponData.AimCFrame,0.2) --Goal CFrame (lower the number, lower the speed is)
  53. else
  54. aimcf = aimcf:Lerp(CFrame.new(), 0.1)
  55. end
  56. end
  57. end)
  58.  
  59. function setup(weapon)
  60. --setup weapon data module
  61. WeaponData = require(GunModules:WaitForChild(weapon))
  62.  
  63. maincf = WeaponData.MainCFrame
  64. larmcf = WeaponData.LArmCFrame
  65. rarmcf = WeaponData.RArmCFrame
  66.  
  67. --setup arms to camera
  68. LArm = RS:WaitForChild("Left Arm"):Clone()
  69. LArm.PrimaryPart = LArm:WaitForChild("Main")
  70. LArm.Parent = cam
  71. for i, part in pairs(LArm:GetChildren()) do
  72. if part:IsA("BasePart") then
  73. part.Anchored = true --Make all the parts anchored so it wont fall off
  74. part.CanCollide = false --make al the parts cant collide so the character wont fly
  75. end
  76. end
  77.  
  78. RArm = RS:WaitForChild("Right Arm"):Clone()
  79. RArm.PrimaryPart = RArm:WaitForChild("Main")
  80. RArm.Parent = cam
  81. for i, part in pairs(RArm:GetChildren()) do
  82. if part:IsA("BasePart") then
  83. part.Anchored = true --Make all the parts anchored so it wont fall off
  84. part.CanCollide = false --make al the parts cant collide so the character wont fly
  85. end
  86. end
  87.  
  88. --setup weapon to camera
  89. WeaponInHand = GunModels:WaitForChild(weapon)
  90. WeaponInHand.PrimaryPart = WeaponInHand:WaitForChild("Handle")
  91. WeaponInHand.Parent = cam
  92. for i, part in pairs(WeaponInHand:GetChildren()) do
  93. if part:IsA("BasePart")then
  94. part.Anchored = true --make all th parts anchored so it wont fall off
  95. part.CanCollide = false --make all the parts can't collide so the charcter won't fly
  96. end
  97. end
  98. end
  99.  
  100. mouse.Button2Down:Connect(function()
  101. aimming = true
  102. end)
  103.  
  104. mouse.Button2Up:Connect(function()
  105. aimming = false
  106. end)
  107.  
  108.  
  109. setup(Primary)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement