Guest User

Untitled

a guest
Apr 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.92 KB | None | 0 0
  1. THE NEW SCRIPT WITH THE NEW ANIMATIONS
  2.  
  3. sp = script.Parent
  4.  
  5. r = game:service("RunService")
  6. debris = game:GetService("Debris")
  7.  
  8. anims = {"RightSlash","LeftSlash","OverHeadSwing","LeftSwingFast","RightSwingFast"}
  9.  
  10. Sounds = {{145180512, "Metal"}, {145180522, "Metal"}, {145180533, "Wood"}, {145180541, "Wood"}, {145180529, "Slash"}, {145180550, "Slash"}}
  11.  
  12. WoodSounds = {}
  13. MetalSounds = {}
  14. SlashSounds = {}
  15.  
  16. basedamage = 10
  17. slashdamage = 20
  18. swingdamage = 30
  19. damage = basedamage
  20.  
  21. sword = sp:WaitForChild('Handle')
  22. sp.Taunting.Value = false
  23.  
  24. local UnsheathSound = Instance.new("Sound")
  25. UnsheathSound.SoundId = "http://www.roblox.com/Asset/?id=145180523"
  26. UnsheathSound.Parent = sword
  27. UnsheathSound.Volume = .2
  28.  
  29. for _,Sound in pairs(Sounds) do
  30. local S = Instance.new("Sound")
  31. S.SoundId = "http://www.roblox.com/Asset/?id=" .. Sound[1]
  32. S.Parent = sword
  33. S.Volume = .2
  34. if Sound[2] == "Wood" then
  35. table.insert(WoodSounds, S)
  36. elseif Sound[2] == "Metal" then
  37. table.insert(MetalSounds, S)
  38. elseif Sound[2] == "Slash" then
  39. table.insert(SlashSounds, S)
  40. end
  41. end
  42.  
  43. function waitfor(parent,name)
  44. while true do
  45. local child = parent:FindFirstChild(name)
  46. if child ~= nil then
  47. return child
  48. end
  49. wait()
  50. end
  51. end
  52.  
  53. waitfor(sp,"Taunting")
  54. waitfor(sp,"RunAnim")
  55. local Halt = false;
  56. function blow(hit)
  57. if hit:findFirstChild("IsShield") then
  58. damage = 0
  59. pcall(function()
  60. if hit.IsShield.Value == "Wood" then
  61. WoodSounds[math.random(#WoodSounds)]:Play()
  62. elseif hit.IsShield.Value == "Metal" then
  63. MetalSounds[math.random(#MetalSounds)]:Play()
  64. else
  65. WoodSounds[math.random(#WoodSounds)]:Play()
  66. end
  67. end);
  68. return
  69. end
  70. if Halt then return end;
  71. Halt = true;
  72. if hit.Parent ~= nil then
  73. local humanoid = hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Human")
  74. local vCharacter = sp.Parent
  75. if vCharacter ~= nil then
  76. local vPlayer = game.Players:playerFromCharacter(vCharacter)
  77. if vPlayer ~= nil then
  78. local hum = vCharacter:findFirstChild("Humanoid") or vCharacter:findFirstChild("Human")
  79. if humanoid ~= nil then
  80. if hum ~= nil and humanoid ~= hum then
  81. local right_arm = vCharacter:FindFirstChild("Right Arm")
  82. if right_arm ~= nil then
  83. local joint = right_arm:FindFirstChild("RightGrip")
  84. if joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword) then
  85. tagHumanoid(humanoid,vPlayer)
  86. humanoid:TakeDamage(damage)
  87. wait(.3)
  88. end
  89. end
  90. end
  91. end
  92. end
  93. end
  94. end
  95. Halt = false;
  96. end
  97.  
  98. function tagHumanoid(humanoid,player)
  99. for i,v in ipairs(humanoid:GetChildren()) do
  100. if v.Name == "creator" then
  101. v:Destroy()
  102. end
  103. end
  104. local creator_tag = Instance.new("ObjectValue")
  105. creator_tag.Value = player
  106. creator_tag.Name = "creator"
  107. creator_tag.Parent = humanoid
  108. debris:AddItem(creator_tag,1)
  109. end
  110.  
  111. sp.Enabled = true
  112. function onActivated()
  113. if sp.Enabled and not sp.Taunting.Value then
  114. sp.Enabled = false
  115. local character = sp.Parent;
  116. local humanoid = character.Humanoid
  117. if humanoid == nil then
  118. print("Humanoid not found")
  119. return
  120. end
  121. SlashSounds[math.random(#SlashSounds)]:Play()
  122. local newanim = anims[math.random(1,#anims)]
  123. while newanim == sp.RunAnim.Value do
  124. newanim = anims[math.random(1,#anims)]
  125. end
  126. sp.RunAnim.Value = newanim
  127. if newanim == "OverHeadSwing" then
  128. damage = swingdamage
  129. else
  130. damage = slashdamage
  131. end
  132. wait(.75)
  133. damage = basedamage
  134. sp.Enabled = true
  135. end
  136. end
  137.  
  138. function onEquipped()
  139. UnsheathSound:play()
  140. end
  141.  
  142. sp.Activated:connect(onActivated)
  143. sp.Equipped:connect(onEquipped)
  144.  
  145. connection = sword.Touched:connect(blow)
  146.  
  147.  
  148.  
  149.  
  150. THE OLD SCRIPT WITH THE OLD ANIMATIONS
  151.  
  152. r = game:GetService("RunService")
  153. ching = false
  154. sword = script.Parent.Handle
  155. Tool = script.Parent
  156. previousHealth = 1
  157. script.Parent.ToolTip = "Base damage: " .. script.Parent.MinDmg.Value .. "-" .. script.Parent.MaxDmg.Value .. " | Critical damage: " .. (script.Parent.CritMagnitude.Value/100).. "x"
  158.  
  159. function blow(hit)
  160. if ching == true then return end
  161. local humanoid = hit.Parent:FindFirstChild("Human") or hit.Parent:FindFirstChild("Humanoid")
  162. local vCharacter = Tool.Parent
  163. local vPlayer = Game.Players:GetPlayerFromCharacter(vCharacter)
  164. --Did the weapon hit player? Check if PvP is enabled.
  165. if humanoid == nil then
  166. local hitPlayer = Game.Players:GetPlayerFromCharacter(hit.Parent)
  167. if hitPlayer ~= nil then
  168. if game.Workspace.GAME_PROPERTIES.HasPvP.Value == true and hitPlayer.Stats.InPvP.Value == true and hitPlayer.leaderstats.Lvl.Value >= game.Workspace.GAME_PROPERTIES.PvPLevelMinimum.Value then --Is the player in PvP areas?
  169. if hitPlayer.leaderstats.Lvl.Value >= vPlayer.leaderstats.Lvl.Value - game.Workspace.GAME_PROPERTIES.PvPLevelRange.Value and hitPlayer.leaderstats.Lvl.Value <= vPlayer.leaderstats.Lvl.Value + game.Workspace.GAME_PROPERTIES.PvPLevelRange.Value then
  170. humanoid = hit.Parent:FindFirstChild("Humanoid")
  171. end
  172. end
  173. end
  174. end
  175. --If humanoid is found, damage.
  176. if humanoid ~= nil then
  177. ching = true
  178. local damage = math.random(script.Parent.MinDmg.Value+math.floor(vPlayer.attributes.Strength.Value/2),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/2))+math.floor(vPlayer.leaderstats.Lvl.Value/5)
  179. local hitroll = math.random(1, 100)
  180. local critroll = math.random(1, 100)
  181. --Is the target a player? Have armor reduce damage taken.
  182. if Game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then
  183. if Game.Workspace.GAME_PROPERTIES.BaseHitChance.Value == 1 then
  184. damage = math.floor(damage * (1 - (Game.Players:GetPlayerFromCharacter(hit.Parent).Stats.Defense.Value / 100)))
  185. elseif Game.Workspace.GAME_PROPERTIES.BaseHitChance.Value == 2 then
  186. damage = math.floor(damage - Game.Players:GetPlayerFromCharacter(hit.Parent).Stats.Defense.Value)
  187. end
  188. if damage < 1 then damage = 1 end --Sets minimum damage to 1.
  189. end
  190. --Hit and critical modifier.
  191. if hitroll > Game.Workspace.GAME_PROPERTIES.BaseHitChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.HitChanceDexMagnitude.Value/100)) then
  192. damage = 0
  193. end
  194. if critroll <= Game.Workspace.GAME_PROPERTIES.BaseCritChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.CritChanceDexMagnitude.Value/100)) then
  195. damage = damage * (script.Parent.CritMagnitude.Value / 100) -- Percentage.
  196. end
  197. --Enemy health bar GUI
  198. if vPlayer.PlayerGui:FindFirstChild("EnemyInfo") ~= nil and humanoid.Health > 0 then
  199. vPlayer.PlayerGui:FindFirstChild("EnemyInfo").EnemyBar.TickUntilRemove.Value = 200
  200. vPlayer.PlayerGui:FindFirstChild("EnemyInfo").EnemyBar.Tag.Value = humanoid.Parent
  201. end
  202. --Damages humanoid
  203. previousHealth = humanoid.Health
  204. humanoid:TakeDamage(damage)
  205. tagHumanoid(humanoid, vPlayer, damage)
  206. --Floating damage text
  207. local part = Instance.new("BillboardGui")
  208. part.Size = UDim2.new(0,50,0,100)
  209. part.StudsOffset = Vector3.new(0,2,0)
  210. local part2 = Instance.new("TextLabel")
  211. dt = Game.ReplicatedStorage.DynamicText:Clone()
  212. part2.Font = "SourceSansBold"
  213. part2.FontSize = "Size24"
  214. part2.TextStrokeTransparency = 1
  215. part2.Size = UDim2.new(1,0,1,0)
  216. part2.Position = UDim2.new(0,0,0,0)
  217. part2.BackgroundTransparency = 1
  218. part2.Parent = part
  219. dt.Parent = part2
  220. dt.Disabled = false
  221. part.Parent = humanoid.Parent.Head
  222. part.Adornee = part.Parent
  223. --Shows text depending on conditions. Tells either miss or number.
  224. if (damage == 0) then
  225. part2.TextColor3 = Color3.new(0,0.5,1)
  226. part2.Text = "Miss!"
  227. else
  228. part2.TextColor3 = Color3.new(1,1,1)
  229. if critroll <= Game.Workspace.GAME_PROPERTIES.BaseCritChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.CritChanceDexMagnitude.Value/100)) then
  230. part2.TextColor3 = Color3.new(1,1,0)
  231. part2.FontSize = "Size36"
  232. part2.Text = ""..damage.."!"
  233. else
  234. part2.Text = ""..damage..""
  235. end
  236. end
  237. wait(1)
  238. ching = false
  239. wait(.1)
  240. --untagHumanoid(humanoid)
  241. end
  242. end
  243.  
  244. function tagHumanoid(humanoid, player, damage)
  245. local creator_tag = Instance.new("ObjectValue", humanoid)
  246. creator_tag.Value = player
  247. creator_tag.Name = "creator"
  248. local damage_tag = Instance.new("IntValue", creator_tag)
  249. if humanoid.Health < 1 then
  250. damage_tag.Value = math.ceil(previousHealth)
  251. else
  252. damage_tag.Value = math.ceil(damage)
  253. end
  254. damage_tag.Name = "damage"
  255. end
  256.  
  257. function untagHumanoid(humanoid)
  258. if humanoid ~= nil then
  259. local tag = humanoid:findFirstChild("creator")
  260. if tag ~= nil then
  261. tag.Parent = nil
  262. end
  263. end
  264. end
  265.  
  266.  
  267. function attack()
  268. local anim = Instance.new("StringValue")
  269. anim.Name = "toolanim"
  270. anim.Value = "Slash"
  271. anim.Parent = Tool
  272. end
  273.  
  274. function lunge()
  275.  
  276. local anim = Instance.new("StringValue")
  277. anim.Name = "toolanim"
  278. anim.Value = "Lunge"
  279. anim.Parent = Tool
  280.  
  281. force = Instance.new("BodyVelocity")
  282. force.velocity = Vector3.new(0,4000,0) --Tool.Parent.Torso.CFrame.lookVector * 80
  283. force.Parent = Tool.Parent.Torso
  284. wait(.25)
  285. swordOut()
  286. wait(.25)
  287. force.Parent = nil
  288. wait(.5)
  289. swordUp()
  290.  
  291. damage = slash_damage
  292. end
  293.  
  294. function swordUp()
  295. Tool.GripForward = Vector3.new(-1,0,0)
  296. Tool.GripRight = Vector3.new(0,1,0)
  297. Tool.GripUp = Vector3.new(0,0,1)
  298. end
  299.  
  300. function swordOut()
  301. Tool.GripForward = Vector3.new(0,0,1)
  302. Tool.GripRight = Vector3.new(0,-1,0)
  303. Tool.GripUp = Vector3.new(-1,0,0)
  304. end
  305.  
  306. function swordAcross()
  307. -- parry
  308. end
  309.  
  310.  
  311. Tool.Enabled = true
  312.  
  313. function onActivated()
  314.  
  315. if not Tool.Enabled then return end
  316.  
  317. Tool.Enabled = false
  318.  
  319. local character = Tool.Parent;
  320. local humanoid = character.Humanoid
  321.  
  322. if humanoid == nil then return end
  323.  
  324. attack()
  325.  
  326. wait(1)
  327.  
  328. Tool.Enabled = true
  329. end
  330.  
  331.  
  332. function onEquipped()
  333.  
  334. end
  335.  
  336.  
  337. script.Parent.Activated:connect(onActivated)
  338. script.Parent.Equipped:connect(onEquipped)
  339.  
  340.  
  341. connection = sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment