Advertisement
djroese

Untitled

Oct 28th, 2016
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.31 KB | None | 0 0
  1.  
  2.  
  3. sp=script.Parent
  4.  
  5.  
  6. damage=666 -- +/- 10%
  7. damagewindow=1 --after clicking, how long does the player have to hit the opponent wioth their weapon to deal damage
  8. swingrate=.75
  9.  
  10. clashsounds={91154405,91154446,91154471,91154503,91154521}
  11. swooshsounds={91154708,91155889,91154405,91154446,91154471,91154503,91154521}
  12. hitsounds={91154909,91154932,91154954,91154405,91154446,91154471,91154503,91154521}
  13. anims={"Stab1","Stab2"}
  14. bloodeffects=false
  15.  
  16.  
  17. ready=false
  18. equipped=false
  19. rate=1/30
  20. lastswing=0
  21.  
  22.  
  23. local reloading=sp:WaitForChild("Reloading")
  24. local down=sp:WaitForChild("MouseDown")
  25. local runanim=sp:WaitForChild("RunAnim")
  26. local sparkles=sp.Handle:WaitForChild("Sparkles")
  27. local debris=game:getService("Debris")
  28. local weaponhud=sp:WaitForChild("WeaponHud")
  29. local weaponnametag=weaponhud:WaitForChild("WeaponName")
  30. local guibar=weaponhud:WaitForChild("Bar")
  31. local guibarfill=guibar:WaitForChild("Fill")
  32. weaponnametag.Text=sp.Name
  33.  
  34. function runsound(id,volume)
  35. local volume=volume or 1
  36. local sound=Instance.new("Sound")
  37. sound.Looped=false
  38. sound.Pitch=.4
  39. sound.SoundId="http://www.roblox.com/asset/?id="..tostring(id)
  40. sound.PlayOnRemove=false
  41. sound.Volume=volume
  42. debris:AddItem(sound,3)
  43. sound.Parent=sp.Handle
  44. wait()
  45. sound:Play()
  46. end
  47.  
  48. function billboard(pos,text,time,color)
  49. local pos=pos or Vector3.new(0,0,0)
  50. local text=text or "Hello World!"
  51. local time=time or 2
  52. local color=color or Color3.new(1,0,0)
  53. local pos=pos+Vector3.new(0,5,0)
  54. local ep=Instance.new("Part")
  55. ep.Name="Effect"
  56. ep.formFactor="Custom"
  57. ep.Size=Vector3.new(0,0,0)
  58. ep.TopSurface="Smooth"
  59. ep.BottomSurface="Smooth"
  60. ep.CFrame=CFrame.new(pos)
  61. ep.Anchored=true
  62. ep.CanCollide=false
  63. ep.Transparency=1
  64. local bb=Instance.new("BillboardGui")
  65. bb.Size=UDim2.new(3,0,3,0)
  66. bb.Adornee=ep
  67. local tl=Instance.new("TextLabel")
  68. tl.BackgroundTransparency=1
  69. tl.Size=UDim2.new(1,0,1,0)
  70. tl.Text=text
  71. tl.TextColor3=color
  72. tl.TextScaled=true
  73. tl.Font="ArialBold"
  74.  
  75. tl.Parent=bb
  76. bb.Parent=ep
  77. debris:AddItem(ep,time+.1)
  78. ep.Parent=game.Workspace
  79. delay(0,function()
  80. local frames=time/rate
  81. for frame=1,frames do
  82. wait(rate)
  83. local percent=frame/frames
  84. ep.CFrame=CFrame.new(pos)+Vector3.new(0,5*percent,0)
  85. tl.TextTransparency=percent
  86. end
  87. ep:remove()
  88. end)
  89. end
  90.  
  91. function makeblood(part)
  92. if part then
  93. local b=Instance.new("Part")
  94. b.BrickColor=BrickColor.new("Bright red")
  95. b.formFactor="Custom"
  96. b.Transparency=math.random(0,1)*.5
  97. if math.random()<.5 then
  98. b.CanCollide=false
  99. else
  100. b.CanCollide=true
  101. end
  102. b.TopSurface="Smooth"
  103. b.BottomSurface="Smooth"
  104. b.Size=Vector3.new(.2*math.random(1,5),.2*math.random(1,5),.2*math.random(1,5))
  105. b.Velocity=part.Velocity+(Vector3.new((math.random()-.5),(math.random()-.5),(math.random()-.5))*30)
  106. b.RotVelocity=part.RotVelocity+(Vector3.new((math.random()-.5),(math.random()-.5),(math.random()-.5))*20)
  107. b.CFrame=part.CFrame*CFrame.new((math.random()-.5)*3,(math.random()-.5)*3,(math.random()-.5)*3)*CFrame.Angles(math.pi*2*math.random(),math.pi*2*math.random(),math.pi*2*math.random())
  108. debris:AddItem(b,math.random()*4)
  109. b.Parent=game.Workspace
  110. end
  111. end
  112.  
  113. sp.Handle.Touched:connect(function(hit)
  114. if ready and equipped and hit and hit.Parent~=nil and hit:IsDescendantOf(sp.Parent)==false and string.lower(string.sub(hit.Name,1,6))~="effect" and (tick()-lastswing)<=damagewindow then
  115. if hit:FindFirstChild("CanBlock") and sp.Handle:FindFirstChild("Blockable") then
  116. ready=false
  117. runsound(clashsounds[math.random(1,#clashsounds)])
  118. sparkles.Enabled=true
  119. delay(.2,function()
  120. sparkles.Enabled=false
  121. end)
  122. billboard(sp.Handle.Position,"Block",2,Color3.new(1,1,0))
  123. end
  124. local mh=sp.Parent:FindFirstChild("Humanoid")
  125. local eh=hit.Parent:FindFirstChild("Humanoid")
  126. local ra=sp.Parent:FindFirstChild("Right Arm")
  127. local plr=game.Players:GetPlayerFromCharacter(sp.Parent)
  128. if mh and eh and eh~=mh and mh.Health>0 and eh.Health>0 and ra and plr~=nil then
  129. local eplr=game.Players:GetPlayerFromCharacter(eh.Parent)
  130. if eplr~=nil and not eplr.Neutral and not plr.Neutral and eplr.TeamColor==plr.TeamColor then
  131. return --No team killing
  132. end
  133. ready=false
  134. for i,v in ipairs(eh:GetChildren()) do
  135. if v.Name=="creator" then
  136. v:remove()
  137. end
  138. end
  139. local creator=Instance.new("ObjectValue")
  140. creator.Name="creator"
  141. creator.Value=plr
  142. creator.Parent=eh
  143. debris:AddItem(creator,1)
  144. local localdamage=math.floor(damage*(.9+(math.random()*.2))+.5)
  145. eh:TakeDamage(localdamage)
  146. billboard(hit.Position,"-"..tostring(localdamage))
  147. runsound(hitsounds[math.random(1,#hitsounds)])
  148. if bloodeffects then
  149. local numbloodeffects=math.ceil(localdamage/10)
  150. for i=1,math.random(numbloodeffects-1,numbloodeffects+1) do
  151. --[[if math.random()<.5 then
  152. makeblood(sp.Handle)
  153. else]]
  154. makeblood(hit)
  155. --end
  156. end
  157. end
  158. end
  159. end
  160. end)
  161.  
  162.  
  163. function Activate()
  164. if equipped and (tick()-lastswing)>=swingrate then
  165. ready=true
  166. reloading.Value=true
  167.  
  168. runsound(swooshsounds[math.random(1,#swooshsounds)],.5)
  169.  
  170. newanim=anims[math.random(1,#anims)]
  171. while newanim==runanim.Value do
  172. newanim=anims[math.random(1,#anims)]
  173. end
  174. runanim.Value=newanim
  175.  
  176. lastswing=tick()
  177.  
  178. wait(swingrate)
  179.  
  180. reloading.Value=false
  181. if down.Value then
  182. Activate()
  183. end
  184. end
  185. end
  186.  
  187. down.Changed:connect(function()
  188. if down.Value then
  189. Activate()
  190. end
  191. end)
  192.  
  193. sp.Equipped:connect(function(mouse)
  194. lastswing=tick()
  195.  
  196. reloading.Value=true
  197. ready=false
  198. equipped=true
  199. local plr=game.Players:GetPlayerFromCharacter(sp.Parent)
  200. if plr~=nil then
  201. local plrgui=plr:FindFirstChild("PlayerGui")
  202. if plrgui~=nil then
  203. weaponhud.Parent=plrgui
  204. end
  205. end
  206.  
  207. wait(swingrate)
  208.  
  209. reloading.Value=false
  210. if down.Value then
  211. Activate()
  212. end
  213. end)
  214.  
  215. sp.Unequipped:connect(function()
  216. ready=false
  217. equipped=false
  218. weaponhud.Parent=sp
  219. end)
  220.  
  221.  
  222. function updategui()
  223. local swingpercent=math.min((tick()-lastswing)/swingrate,1)
  224. if swingpercent<.5 then --fade from red to yellow then to green
  225. guibarfill.BackgroundColor3=Color3.new(1,swingpercent*2,0)
  226. else
  227. guibarfill.BackgroundColor3=Color3.new(1-((swingpercent-.5)/.5),1,0)
  228. end
  229. guibarfill.Size=UDim2.new(swingpercent,0,1,0)
  230. end
  231. while true do
  232. updategui()
  233. wait(rate)
  234. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement