daily pastebin goal
0%
SHARE
TWEET

Untitled

Extreezy Dec 14th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Wait(.1)
  2.  
  3. Player = game.Players.LocalPlayer
  4. Character = Player.Character
  5. LArm = Character:FindFirstChild("Left Arm")
  6. Torso = Character:FindFirstChild("Torso")
  7. Shoulder = Torso:FindFirstChild("Left Shoulder")
  8.  
  9. ShieldTemplate = script:WaitForChild("ShieldTemplate")
  10. VariantShield = script:WaitForChild("VariantShield")
  11. RemoveFunction = script:WaitForChild("RemoveShield")
  12.  
  13. Use = false
  14. DataY = 0
  15. Up = false
  16. Down = false
  17. Busy = false
  18. AnimationSpeed = 5 -- Slower, smoother with more integers
  19.  
  20. ShieldLink = nil
  21. Weld = nil
  22. LeftShoulderMotor = nil
  23.  
  24. local function WeldDecoration(Variant, WeldTo)
  25.     local g = Variant:Clone()
  26.     g.Parent = WeldTo.Parent
  27.     local C = g:GetChildren()
  28.     for i = 1, #C do
  29.         if C[i]:IsA("BasePart") then
  30.             C[i].CanCollide = true
  31.             local W = Instance.new("Weld")
  32.             W.Part0 = g.Middle
  33.             W.Part1 = C[i]
  34.             local CJ = CFrame.new(g.Middle.Position)
  35.             local C0 = g.Middle.CFrame:inverse()*CJ
  36.             local C1 = C[i].CFrame:inverse()*CJ
  37.             W.C0 = C0
  38.             W.C1 = C1
  39.             W.Parent = g.Middle
  40.         end
  41.        
  42.         local Y = Instance.new("Weld")
  43.         Y.Part0 = WeldTo
  44.         Y.Part1 = g.Middle
  45.         Y.C0 = CFrame.new(0, 0, 0)
  46.         Y.Parent = Y.Part0
  47.     end
  48.  
  49.     local h = g:GetChildren()
  50.     for i = 1, # h do
  51.         h[i].Anchored = false
  52.         h[i].CanCollide = false
  53.     end
  54. end
  55.  
  56. local function CreateShield()
  57.     Shield = ShieldTemplate:Clone()
  58.     Shield.Name = "Shield"
  59.     Shield.Parent = Character
  60.     WeldDecoration(VariantShield, Shield.Handle)
  61.     Shield:MoveTo(Character.Torso.Position)
  62.     ShieldWeld = Instance.new("Weld", Shield)
  63.     ShieldWeld.Part0 = LArm
  64.     ShieldWeld.Part1 = Shield.Handle
  65.    
  66.     ShieldTag = Instance.new("StringValue", Shield.Handle)
  67.     ShieldTag.Name = "IsShield"
  68.     ShieldTag.Value = "Wood"
  69.    
  70.     ShieldWeld.C0 = CFrame.new(-0.175, -0.1, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(90), 0)
  71.     ShieldLink = Shield
  72. end
  73.  
  74. function CommandIssued(Type, Data)
  75.     if Type == "KeyPress" and Data ~= nil then
  76.         Key = Data:lower()
  77.         if Key == "q" then
  78.             if not Use and not Busy then
  79.                 Busy = true
  80.                 if not Character:FindFirstChild("Shield") then
  81.                     CreateShield()
  82.                 end
  83.                 LeftShoulderMotor = Torso["Left Shoulder"].C1 -- Save data
  84.                 Shoulder.Part1 = nil -- Disconnect arm from shoulder
  85.                 Weld = Instance.new("Weld") -- New Weld LeftArm to Torso
  86.                 Weld.Name = "LeftArm Weld"
  87.                 Weld.Part0 = Torso
  88.                 Weld.Part1 = LArm
  89.                 Weld.Parent = Torso
  90.                 Weld.C0 = CFrame.new(-1.5,0,0) -- Reposition arm
  91.                
  92.                 for i = 1,AnimationSpeed do
  93.                     Weld.C0 = Weld.C0 * CFrame.new(0.5/AnimationSpeed,-0.25/AnimationSpeed,-1/AnimationSpeed)*CFrame.fromEulerAnglesXYZ(math.rad(70/AnimationSpeed),math.rad(-40/AnimationSpeed),math.rad(40/AnimationSpeed)) -- if you tweak the numbers long enough you manage to get a smooth animation, sometimes it takes really long until you finally get all the positions right but when it comes to cframe/Weld manipulation the best way to achieve the wanted formula is trough trial and error
  94.                     Wait()
  95.                 end
  96.                
  97.                 Busy = false
  98.                 Use = true
  99.             else
  100.                 if not Busy then
  101.                     Busy = true
  102.                     if DataY > 0 then
  103.                         for i = 1, DataY do
  104.                             DataY = DataY - 1
  105.                             Weld.C0 = Weld.C0 * CFrame.new(0,0,0.04)*CFrame.fromEulerAnglesXYZ(math.rad(-3),math.rad(1),math.rad(0))
  106.                             if ShieldWeld ~= nil then
  107.                                 ShieldWeld.C0 = ShieldWeld.C0 * CFrame.new(.02, 0, .015) * CFrame.fromEulerAnglesXYZ(math.rad(.9), math.rad(-2), math.rad(.75)) -- SHIELD WELD HERE
  108.                             end
  109.                             Wait()
  110.                         end
  111.                     end
  112.                     for i = 1, AnimationSpeed do
  113.                         Weld.C0 = Weld.C0*CFrame.new(-0.5/AnimationSpeed,0.25/AnimationSpeed,1/AnimationSpeed)*CFrame.fromEulerAnglesXYZ(math.rad(-70/AnimationSpeed),math.rad(40/AnimationSpeed),math.rad(-40/AnimationSpeed)) -- the equiping animation reversed
  114.                         Wait()
  115.                     end
  116.                     ShieldWeld.C0 = CFrame.new(-0.175, -0.1, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(90), 0)
  117.                     Weld:Destroy()
  118.                     Shoulder.Part1 = LArm
  119.                     Shoulder.C1 = LeftShoulderMotor
  120.                     DataY = 0
  121.                     Use = false
  122.                     Busy = false
  123.                 end
  124.             end
  125.         elseif Key == "r" then
  126.             if Up == false and Down == false and Use == true and Busy == false then
  127.                 Up = true
  128.                 while Up == true and DataY < 30 do
  129.                     DataY = DataY + 1
  130.                     Weld.C0 = Weld.C0 * CFrame.new(0, 0, -0.04) * CFrame.fromEulerAnglesXYZ(math.rad(3),math.rad(-1),math.rad(0))
  131.                     if ShieldWeld ~= nil then
  132.                         ShieldWeld.C0 = ShieldWeld.C0 * CFrame.new(-.02, 0, -.015) * CFrame.fromEulerAnglesXYZ(math.rad(-.9), math.rad(2), math.rad(-.75)) -- SHIELD WELD HERE
  133.                     end
  134.                     Wait()
  135.                 end
  136.             end
  137.         elseif Key == "f" then
  138.             if Down == false and Up == false and Use == true and Busy == false then
  139.                 Down = true
  140.                 while Down == true and DataY > 0 do
  141.                     DataY = DataY-1
  142.                     Weld.C0 = Weld.C0 * CFrame.new(0, 0, 0.04) * CFrame.fromEulerAnglesXYZ(math.rad(-3),math.rad(1),math.rad(0))
  143.                     if ShieldWeld ~= nil then
  144.                         ShieldWeld.C0 = ShieldWeld.C0 * CFrame.new(.02, 0, .015) * CFrame.fromEulerAnglesXYZ(math.rad(.9), math.rad(-2), math.rad(.75)) -- SHIELD WELD HERE
  145.                     end
  146.                     Wait()
  147.                 end
  148.             end
  149.         end
  150.     elseif Type == "Remove" then
  151.         if Weld then
  152.             Weld:Destroy()
  153.         end
  154.         Shoulder.Part1 = LArm
  155.         if ShieldLink then
  156.             ShieldLink:Destroy()
  157.         end
  158.     end
  159. end
  160.  
  161. function CommandStopped(Key)
  162.     Key = Key:lower()
  163.     if Key == "r" then
  164.         Up = false
  165.     elseif Key == "f" then
  166.         Down = false
  167.     end
  168. end
  169.  
  170. function RemoveFunction.OnClientInvoke()
  171.     CommandIssued("Remove")
  172. end
  173.  
  174. CreateShield()
  175.  
  176. Player:GetMouse().KeyDown:connect(function(Key)
  177.     CommandIssued("KeyPress", Key)
  178. end)
  179.  
  180. Player:GetMouse().KeyUp:connect(CommandStopped)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top