Advertisement
HenloMyDude

sword transformation thing

Nov 3rd, 2019
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1.  
  2. plr = owner
  3. equip = false
  4. char = Instance.new("Model",script)
  5. char.Name = plr.Name .." Sword"
  6. tool = Instance.new("Tool",nil)
  7. tool.Name = plr.Name .." Sword"
  8. tool.GripForward = Vector3.new(-1, 0, 0)
  9. tool.GripPos = Vector3.new(0, 0, -1.5)
  10. tool.GripRight = Vector3.new(0, 1, 0)
  11. tool.GripUp = Vector3.new(0, 0, 1)
  12. dmg = 0
  13. Animations = {
  14. R15Slash = 522635514,
  15. R15Lunge = 522638767
  16. }
  17. Grips = {
  18. Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
  19. Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
  20. }
  21. function Create(ty)
  22. return function(data)
  23. local obj = Instance.new(ty)
  24. for k, v in pairs(data) do
  25. if type(k) == 'number' then
  26. v.Parent = obj
  27. else
  28. obj[k] = v
  29. end
  30. end
  31. return obj
  32. end
  33. end
  34. BaseUrl = "rbxassetid://"
  35. function attack()
  36. local Humanoid = tool.Parent:FindFirstChildOfClass("Humanoid")
  37. dmg = 5
  38. local s = Instance.new("Sound",main) s.Volume = 0.6 s.SoundId = "rbxassetid://12222216" s:Play()
  39. if Humanoid then
  40. if Humanoid.RigType == Enum.HumanoidRigType.R6 then
  41. local Anim = Instance.new("StringValue")
  42. Anim.Name = "toolanim"
  43. Anim.Value = "Slash"
  44. Anim.Parent = tool
  45. elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
  46. local Anim = tool:FindFirstChild("R15Slash")
  47. if Anim then
  48. local Track = Humanoid:LoadAnimation(Anim)
  49. Track:Play(0)
  50. end
  51. end
  52. end
  53. wait(.5)
  54. dmg = 0
  55. end
  56. function lunge()
  57. local Humanoid = tool.Parent:FindFirstChildOfClass("Humanoid")
  58. dmg = 20
  59. local s = Instance.new("Sound",main) s.Volume = 0.6 s.SoundId = "rbxassetid://12222208" s:Play()
  60. if Humanoid then
  61. if Humanoid.RigType == Enum.HumanoidRigType.R6 then
  62. local Anim = Instance.new("StringValue")
  63. Anim.Name = "toolanim"
  64. Anim.Value = "Lunge"
  65. Anim.Parent = tool
  66. elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
  67. local Anim = tool:FindFirstChild("R15Lunge")
  68. if Anim then
  69. local Track = Humanoid:LoadAnimation(Anim)
  70. Track:Play(0)
  71. end
  72. end
  73. end
  74. wait(0.2)
  75. tool.Grip = Grips.Out
  76. wait(0.6)
  77. tool.Grip = Grips.Up
  78. dmg = 0
  79. end
  80. LastAttack = 0
  81. tool.Activated:connect(function()
  82. local Tick = game:GetService("RunService").Stepped:wait()
  83. tool.Enabled = false
  84. if (Tick - LastAttack < 0.2) then
  85. lunge()
  86. else
  87. attack()
  88. end
  89. LastAttack = Tick
  90. local SlashAnim = (tool:FindFirstChild("R15Slash") or Create("Animation"){
  91. Name = "R15Slash",
  92. AnimationId = BaseUrl .. Animations.R15Slash,
  93. Parent = tool
  94. })
  95.  
  96. local LungeAnim = (tool:FindFirstChild("R15Lunge") or Create("Animation"){
  97. Name = "R15Lunge",
  98. AnimationId = BaseUrl .. Animations.R15Lunge,
  99. Parent = tool
  100. })
  101. dmg = 0
  102. tool.Enabled = true
  103. end)
  104. face = plr.Character.Head:FindFirstChild("face")
  105. if face then
  106. tool.TextureId = face.Texture
  107. end
  108. main = Instance.new("Part",char)
  109. main.Size = Vector3.new(2.5, 4, 1)
  110. main.BrickColor = plr.Character.Head.BrickColor
  111. main.Material = "Plastic"
  112. main.Name = "Handle"
  113. main.Size = Vector3.new(1, 0.8, 4)
  114. main.Position = plr.Character.Head.Position
  115. main.Touched:connect(function(hit)
  116. local nub = hit.Parent
  117. for _,v in pairs (nub:children()) do
  118. if v:IsA("Humanoid") then
  119. v.Health = v.Health - dmg
  120. end
  121. end
  122. end)
  123. newface = Instance.new("Decal",main)
  124. if face then
  125. newface.Texture = face.Texture
  126. end
  127. newface.Face = "Back"
  128. detect = Instance.new("ClickDetector",main)
  129. detect.MaxActivationDistance = 16
  130. detect.MouseClick:connect(function(player)
  131. if player ~= owner then
  132. main.Parent = tool
  133. tool.Parent = player.Backpack
  134. detect:Destroy()
  135. end
  136. end)
  137. plr.Character.Parent = nil
  138. plr.Character = char
  139. NLS([[
  140.  
  141. workspace.CurrentCamera.CameraSubject = owner.Character.Handle
  142.  
  143. ]],char)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement