Advertisement
EdgyHedgehog

Cane

Dec 27th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.81 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,game,owner = owner,game
  3. local RealPlayer = Player
  4. do
  5. print("FE Compatibility code by Mokiros")
  6. local rp = RealPlayer
  7. script.Parent = rp.Character
  8.  
  9. --RemoteEvent for communicating
  10. local Event = Instance.new("RemoteEvent")
  11. Event.Name = "UserInput_Event"
  12.  
  13. --Fake event to make stuff like Mouse.KeyDown work
  14. local function fakeEvent()
  15. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  16. t.connect = t.Connect
  17. return t
  18. end
  19.  
  20. --Creating fake input objects with fake variables
  21. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  22. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  23. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  24. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  25. end}
  26. --Merged 2 functions into one by checking amount of arguments
  27. CAS.UnbindAction = CAS.BindAction
  28.  
  29. --This function will trigger the events that have been :Connect()'ed
  30. local function te(self,ev,...)
  31. local t = m[ev]
  32. if t and t._fakeEvent then
  33. for _,f in pairs(t.Functions) do
  34. f(...)
  35. end
  36. end
  37. end
  38. m.TrigEvent = te
  39. UIS.TrigEvent = te
  40.  
  41. Event.OnServerEvent:Connect(function(plr,io)
  42. if plr~=rp then return end
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. if not io.isMouse then
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. for _,t in pairs(CAS.Actions) do
  51. for _,k in pairs(t.Keys) do
  52. if k==io.KeyCode then
  53. t.Function(t.Name,io.UserInputState,io)
  54. end
  55. end
  56. end
  57. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59. end
  60. end)
  61. Event.Parent = NLS([==[
  62. local Player = game:GetService("Players").LocalPlayer
  63. local Event = script:WaitForChild("UserInput_Event")
  64.  
  65. local Mouse = Player:GetMouse()
  66. local UIS = game:GetService("UserInputService")
  67. local input = function(io,a)
  68. if a then return end
  69. --Since InputObject is a client-side instance, we create and pass table instead
  70. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  71. end
  72. UIS.InputBegan:Connect(input)
  73. UIS.InputEnded:Connect(input)
  74.  
  75. local h,t
  76. --Give the server mouse data 30 times every second, but only if the values changed
  77. --If player is not moving their mouse, client won't fire events
  78. while wait(1/30) do
  79. if h~=Mouse.Hit or t~=Mouse.Target then
  80. h,t=Mouse.Hit,Mouse.Target
  81. Event:FireServer({isMouse=true,Target=t,Hit=h})
  82. end
  83. end]==],Player.Character)
  84.  
  85. ----Sandboxed game object that allows the usage of client-side methods and services
  86. --Real game object
  87. local _rg = game
  88.  
  89. --Metatable for fake service
  90. local fsmt = {
  91. __index = function(self,k)
  92. local s = rawget(self,"_RealService")
  93. if s then return s[k] end
  94. end,
  95. __newindex = function(self,k,v)
  96. local s = rawget(self,"_RealService")
  97. if s then s[k]=v end
  98. end,
  99. __call = function(self,...)
  100. local s = rawget(self,"_RealService")
  101. if s then return s(...) end
  102. end
  103. }
  104. local function FakeService(t,RealService)
  105. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  106. return setmetatable(t,fsmt)
  107. end
  108.  
  109. --Fake game object
  110. local g = {
  111. GetService = function(self,s)
  112. return self[s]
  113. end,
  114. Players = FakeService({
  115. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  116. },"Players"),
  117. UserInputService = FakeService(UIS,"UserInputService"),
  118. ContextActionService = FakeService(CAS,"ContextActionService"),
  119. }
  120. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  121. g.service = g.GetService
  122.  
  123. g.RunService = FakeService({
  124. RenderStepped = _rg:GetService("RunService").Heartbeat,
  125. BindToRenderStep = function(self,name,_,fun)
  126.  
  127. end,
  128. UnbindFromRenderStep = function(self,name)
  129. self._btrs[name]:Disconnect()
  130. end,
  131. },"RunService")
  132.  
  133. setmetatable(g,{
  134. __index=function(self,s)
  135. return _rg:GetService(s) or typeof(_rg[s])=="function"
  136. and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  137. end,
  138. __newindex = fsmt.__newindex,
  139. __call = fsmt.__call
  140. })
  141. --Changing owner to fake player object to support owner:GetMouse()
  142. game,owner = g,g.Players.LocalPlayer
  143. end
  144. -----------------------------
  145. -- Initial stuff
  146. math.randomseed(tick())
  147.  
  148.  
  149. -- Wait for character
  150. repeat wait() until game.Players.LocalPlayer.Character ~= nil
  151.  
  152.  
  153. -- Useful shortcuts
  154. local plr = owner
  155. local char = plr.Character
  156. local plrgui = plr.PlayerGui
  157. local backpack = plr.Backpack
  158. local torso = char.Torso
  159. local head = char.Head
  160. local hum = char.Humanoid
  161. local larm = char["Left Arm"]
  162. local lleg = char["Left Leg"]
  163. local rarm = char["Right Arm"]
  164. local rleg = char["Right Leg"]
  165. local LS = torso["Left Shoulder"]
  166. local LH = torso["Left Hip"]
  167. local RS = torso["Right Shoulder"]
  168. local RH = torso["Right Hip"]
  169. local neck = torso.Neck
  170. local it = Instance.new
  171. local vt = Vector3.new
  172. local cf = CFrame.new
  173. local euler = CFrame.fromEulerAnglesXYZ
  174. local angles = CFrame.Angles
  175. local neckC0 = cf(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  176. local neckC1 = cf(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  177. local LSC0 = cf(-1.5,.5,0)
  178. local LSC1 = cf(0,.5,0)
  179. local RSC0 = cf(1.5,.5,0)
  180. local RSC1 = cf(0,.5,0)
  181. local LHC0 = cf(-1,-1,0,-0,-0,-1,0,1,0,1,0,0)
  182. local LHC1 = cf(-0.5,1,0,-0,-0,-1,0,1,0,1,0,0)
  183. local RHC0 = cf(1,-1,0,0,0,1,0,1,0,-1,-0,-0)
  184. local RHC1 = cf(0.5,1,0,0,0,1,0,1,0,-1,-0,-0)
  185. local RP = char.HumanoidRootPart
  186. local RJ = RP.RootJoint
  187. local RJC0 = euler(-1.57,0,3.14)
  188.  
  189.  
  190. -- Build the weapon
  191. local build = function()
  192. local model = Instance.new("Model")
  193. model.Name = "Cane"
  194. local handle = Instance.new("Part", model)
  195. handle.FormFactor = Enum.FormFactor.Symmetric
  196. handle.CanCollide = false
  197. handle.Size = Vector3.new(1,1,3)
  198. handle.Name = "Handle"
  199. local mesh = Instance.new("SpecialMesh",handle)
  200. mesh.Scale = Vector3.new(1,1,0.69999998807907)
  201. mesh.MeshId = "http://www.roblox.com/asset/?id=25628815"
  202. mesh.TextureId = "http://www.roblox.com/asset/?id=25629094"
  203. mesh.MeshType = Enum.MeshType.FileMesh
  204. return model
  205. end
  206.  
  207.  
  208. -- Wait for mouse
  209. local mouse
  210. while true do
  211. mouse = plr:GetMouse()
  212. if mouse then break end
  213. wait(.1)
  214. end
  215.  
  216.  
  217. -- Create welds
  218. local RW, LW = Instance.new("Weld",torso), Instance.new("Weld",torso)
  219. RW.Name = "Right Weld" LW.Name = "Left Weld"
  220. RW.Part0 = torso LW.Part0 = torso
  221. RW.C0 = RSC0 RW.C1 = RSC1 LW.C0 = LSC0 LW.C1 = LSC1
  222.  
  223.  
  224. -- Attach weapon
  225. local canemodel = build()
  226. local cane = canemodel:FindFirstChild("Handle")
  227. canemodel.Parent = char
  228. local caneweld = Instance.new("Weld", rarm)
  229. caneweld.Part0 = rarm
  230. caneweld.Part1 = cane
  231. caneweldC0 = caneweld.C0 * CFrame.new(0,-1,1) * CFrame.Angles(math.rad(180),0,math.rad(90))
  232. caneweld.C0 = caneweldC0
  233.  
  234.  
  235. -- Weapon variables
  236. local caneEnd = cf(-.225,0,-1.5)
  237.  
  238.  
  239. -- Sound effects
  240. local sounds = {}
  241. sounds.explosion = "http://www.roblox.com/asset/?id=87784452"
  242. sounds.bewm = "http://www.roblox.com/asset/?id=2767090"
  243. sounds.slice = "http://www.roblox.com/asset/?id=161006195"
  244. sounds.charge = "http://roblox.com/asset/?id=2101137"
  245. sounds.sharpblast = "http://roblox.com/asset/?id=2248511"
  246. sounds.woosh = "http://roblox.com/asset/?id=147722227"
  247. sounds.metalhit = "http://roblox.com/asset/?id=153092348"
  248. sounds.mechblast = "http://roblox.com/asset/?id=169380505"
  249. sounds.chargepulse = "http://roblox.com/asset/?id=10209296"
  250. sounds.heal = "http://roblox.com/asset/?id=2101144"
  251. sounds.zap = "http://roblox.com/asset/?id=10756104"
  252. sounds.powernote = "http://roblox.com/asset/?id=192603389"
  253. sounds.swing = "http://roblox.com/asset/?id=10209640"
  254. sounds.hit = "http://roblox.com/asset/?id=10209590"
  255.  
  256.  
  257. -- Base functions
  258. local wait = function(t)
  259. if t ~= nil then
  260. return wait(t)
  261. else
  262. local t = tick()
  263. game:GetService("RunService").RenderStepped:wait()
  264. return tick() - t, time()
  265. end
  266. end
  267. local nolines = function(p)
  268. p.TopSurface, p.BottomSurface, p.LeftSurface, p.RightSurface, p.FrontSurface, p.BackSurface = 10, 10, 10, 10, 10, 10
  269. end
  270. local part = function(formfactor,parent,reflectance,transparency,brickcolor,name,size)
  271. local fp = it("Part")
  272. fp.formFactor = formfactor
  273. fp.Parent = parent
  274. fp.Reflectance = reflectance
  275. fp.Transparency = transparency
  276. fp.CanCollide = false
  277. fp.Locked = true
  278. fp.BrickColor = brickcolor
  279. fp.Name = name
  280. fp.Size = size
  281. fp.Position = torso.Position
  282. fp.Material = "SmoothPlastic"
  283. fp:BreakJoints()
  284. nolines(fp)
  285. return fp
  286. end
  287. local mesh = function(instance,part,meshtype,meshid,offset,scale)
  288. local mesh = it(instance)
  289. mesh.Parent = part
  290. if instance == "SpecialMesh" then
  291. mesh.MeshType = meshtype
  292. if meshid ~= nil then
  293. mesh.MeshId = "http://www.roblox.com/asset/?id="..meshid
  294. end
  295. end
  296. mesh.Offset=offset
  297. mesh.Scale=scale
  298. return mesh
  299. end
  300. local weld = function(parent,part0,part1,c0)
  301. local weld = it("Weld")
  302. weld.Parent = parent
  303. weld.Part0 = part0
  304. weld.Part1 = part1
  305. weld.C0 = c0
  306. return weld
  307. end
  308. local rayCast = function(Pos, Dir, Max, Ignore) -- Origin Position , Direction, MaxDistance , IgnoreDescendants
  309. return game:service("Workspace"):FindPartOnRay(Ray.new(Pos, Dir.unit * (Max or 999.999)), Ignore)
  310. end
  311. local rad = function(x,y,z)
  312. return euler(math.rad(x or 0),math.rad(y or 0),math.rad(z or 0))
  313. end
  314. local random = function(a, b)
  315. local num = math.random(a*100, b*100)
  316. return num/100
  317. end
  318. local randomRot = function()
  319. return rad(random(0,360),random(0,360),random(0,360))
  320. end
  321. local sound = function(id, par, vol, pit)
  322. coroutine.resume(coroutine.create(function()
  323. local sou = Instance.new("Sound", par or workspace)
  324. sou.Volume = vol
  325. sou.Pitch = pit or 1
  326. sou.SoundId = id
  327. wait()
  328. sou:play()
  329. game:GetService("Debris"):AddItem(sou, 6)
  330. end))
  331. end
  332. local damage = function(hit, minim, maxim, knockback, Type, Property, Delay, KnockbackType, incstun, stagger, staghit, ranged)
  333. -- Fen's nasty and messy damage function
  334. if hit.Parent == nil then
  335. return
  336. end
  337. local h = hit.Parent:FindFirstChild("Humanoid")
  338. for _, v in pairs(hit.Parent:children()) do
  339. if v:IsA("Humanoid") then
  340. h = v
  341. end
  342. end
  343. if hit.Parent.Parent:FindFirstChild("Torso") ~= nil then
  344. h = hit.Parent.Parent:FindFirstChild("Humanoid")
  345. end
  346. if hit.Parent.className == "Hat" then
  347. hit = hit.Parent.Parent:findFirstChild("Head")
  348. end
  349. if h ~= nil and hit.Parent.Name ~= char.Name and hit.Parent:FindFirstChild("Torso") ~= nil then
  350. if hit.Parent:findFirstChild("DebounceHit") ~= nil then
  351. if hit.Parent.DebounceHit.Value == true then
  352. return
  353. end
  354. end
  355. local c = Instance.new("ObjectValue")
  356. c.Name = "creator"
  357. c.Value = game:service("Players").LocalPlayer
  358. c.Parent = h
  359. game:GetService("Debris"):AddItem(c, .5)
  360. local Damage = random(minim, maxim)
  361. local blocked = false
  362. local enblock = nil
  363. local Stats = hit.Parent:findFirstChild("Stats")
  364. if Stats ~= nil then
  365. enblock = Stats:findFirstChild("Block")
  366. if Stats:findFirstChild("Defense") ~= nil then
  367. Damage = Damage / Stats.Defense.Value
  368. end
  369. if Stats:findFirstChild("Stun") ~= nil then
  370. Stats.Stun.Value = Stats.Stun.Value + incstun
  371. end
  372. if Stats:findFirstChild("Stagger") ~= nil then
  373. if stagger == true then
  374. Stats.Stagger.Value = true
  375. end
  376. end
  377. end
  378. if enblock ~= nil then
  379. if enblock.Value == true then
  380. blocked = true
  381. end
  382. end
  383. if blocked == true then
  384. if ranged ~= true then
  385. enblock.Value = false
  386. end
  387. else
  388. Damage = math.floor(Damage)
  389. print("dam"..Damage)
  390. sound(sounds.hit, hit, 1, 1)
  391. h.Health = h.Health - Damage
  392. if Type == "Knockdown" then
  393. local hum = hit.Parent.Humanoid
  394. hum.PlatformStand = true
  395. coroutine.resume(coroutine.create(function(HHumanoid)
  396. wait()
  397. HHumanoid.PlatformStand = false
  398. end), hum)
  399. local angle = (hit.Position - (Property.Position + Vector3.new(0, 0, 0))).unit
  400. local bodvol = Instance.new("BodyVelocity")
  401. bodvol.velocity = angle * knockback
  402. bodvol.P = 5000
  403. bodvol.maxForce = Vector3.new(8e+003, 8e+003, 8e+003)
  404. bodvol.Parent = hit
  405. local rl = Instance.new("BodyAngularVelocity")
  406. rl.P = 3000
  407. rl.maxTorque = Vector3.new(500000, 500000, 500000) * 50000000000000
  408. rl.angularvelocity = Vector3.new(random(-10, 10), random(-10, 10), random(-10, 10))
  409. rl.Parent = hit
  410. game:GetService("Debris"):AddItem(bodvol, .5)
  411. game:GetService("Debris"):AddItem(rl, .5)
  412. elseif Type == "Knockdown2" then
  413. local hum = hit.Parent.Humanoid
  414. local angle = (hit.Position - (Property.Position + Vector3.new(0, 0, 0))).unit
  415. local bodvol = Instance.new("BodyVelocity")
  416. bodvol.velocity = angle * knockback
  417. bodvol.P = 5000
  418. bodvol.maxForce = Vector3.new(8e+003, 8e+003, 8e+003)
  419. bodvol.Parent = hit
  420. game:GetService("Debris"):AddItem(bodvol, .5)
  421. elseif Type == "Normal" or Type == "NormalDecreaseMvmt1" then
  422. local vp = Instance.new("BodyVelocity")
  423. vp.P = 500
  424. vp.maxForce = Vector3.new(math.huge, 0, math.huge)
  425. if KnockbackType == 1 then
  426. vp.velocity = Property.CFrame.lookVector * knockback + Property.Velocity / 1.05
  427. elseif KnockbackType == 2 then
  428. vp.velocity = Property.CFrame.lookVector * knockback
  429. end
  430. game:GetService("Debris"):AddItem(vp, .5)
  431. if knockback > 0 then
  432. vp.Parent = hit.Parent.Torso
  433. end
  434. end
  435. end
  436. local debounce = Instance.new("BoolValue")
  437. debounce.Name = "DebounceHit"
  438. debounce.Parent = hit.Parent
  439. debounce.Value = true
  440. game:GetService("Debris"):AddItem(debounce, Delay)
  441. c = Instance.new("ObjectValue")
  442. c.Name = "creator"
  443. c.Value = plr
  444. c.Parent = h
  445. game:GetService("Debris"):AddItem(c, .5)
  446. end
  447. end
  448. local fade = function(prt, t)
  449. coroutine.resume(coroutine.create(function()
  450. for i = 0, 1, t do
  451. wait(0)
  452. prt.Transparency = i
  453. end
  454. wait(0)
  455. prt:destroy()
  456. end))
  457. end
  458. local block1 = function(prt, delay, x, y, z, msh)
  459. coroutine.resume(coroutine.create(function()
  460. for i = 0, 1, delay do
  461. wait(0)
  462. prt.CFrame = prt.CFrame * euler(random(-50, 50), random(-50, 50), random(-50, 50))
  463. local Mesh = msh
  464. Mesh.Scale = Mesh.Scale + vt(x, y, z)
  465. prt.Transparency = i
  466. end
  467. wait(0)
  468. prt:destroy()
  469. end))
  470. end
  471. local block2 = function(prt, delay, x, y, z, msh)
  472. coroutine.resume(coroutine.create(function()
  473. for i = 0, 1, delay do
  474. wait(0)
  475. local Mesh = msh
  476. Mesh.Scale = Mesh.Scale + vt(x, y, z)
  477. prt.Transparency = i
  478. end
  479. wait(0)
  480. prt:destroy()
  481. end))
  482. end
  483. local cyleffect = function(prt, delay, x, y, z, msh)
  484. coroutine.resume(coroutine.create(function()
  485. for i = 0, 1, delay do
  486. wait(0)
  487. local Mesh = msh
  488. Mesh.Scale = Mesh.Scale + vt(x, y, z)
  489. prt.Transparency = i
  490. end
  491. wait(0)
  492. prt:destroy()
  493. end))
  494. end
  495. local CFrameFromTopBack = function(at, top, back)
  496. local right = top:Cross(back)
  497. return CFrame.new(at.x, at.y, at.z,
  498. right.x, top.x, back.x,
  499. right.y, top.y, back.y,
  500. right.z, top.z, back.z)
  501. end
  502. local triangle = function(a, b, c)
  503. local edg1 = (c - a):Dot((b - a).unit)
  504. local edg2 = (a - b):Dot((c - b).unit)
  505. local edg3 = (b - c):Dot((a - c).unit)
  506. if edg1 <= (b - a).magnitude and edg1 >= 0 then
  507. a, b, c = a, b, c
  508. elseif edg2 <= (c - b).magnitude and edg2 >= 0 then
  509. a, b, c = b, c, a
  510. elseif edg3 <= (a - c).magnitude and edg3 >= 0 then
  511. a, b, c = c, a, b
  512. else
  513. assert(false, "unreachable")
  514. end
  515. local len1 = (c - a):Dot((b - a).unit)
  516. local len2 = (b - a).magnitude - len1
  517. local width = (a + (b - a).unit * len1 - c).magnitude
  518. local maincf = CFrameFromTopBack(a, (b - a):Cross(c - b).unit, -(b - a).unit)
  519. local list = {}
  520. if len1 > 0.01 then
  521. local w1 = Instance.new('WedgePart', m)
  522. game:GetService("Debris"):AddItem(w1, 5)
  523. w1.Material = "SmoothPlastic"
  524. w1.FormFactor = 'Custom'
  525. w1.BrickColor = BrickColor.new("Bright red")
  526. w1.Transparency = 0
  527. w1.Reflectance = 0
  528. w1.Material = "SmoothPlastic"
  529. w1.CanCollide = false
  530. nolines(w1)
  531. local sz = Vector3.new(0.2, width, len1)
  532. w1.Size = sz
  533. local sp = Instance.new("SpecialMesh", w1)
  534. sp.MeshType = "Wedge"
  535. sp.Scale = Vector3.new(0, 1, 1) * sz / w1.Size
  536. w1:BreakJoints()
  537. w1.Anchored = true
  538. w1.Parent = workspace
  539. w1.Transparency = 0.7
  540. fade(w1)
  541. w1.CFrame = maincf * CFrame.Angles(math.pi, 0, math.pi / 2) * CFrame.new(0, width / 2, len1 / 2)
  542. table.insert(list, w1)
  543. end
  544. if len2 > 0.01 then
  545. local w2 = Instance.new('WedgePart', m)
  546. game:GetService("Debris"):AddItem(w2, 5)
  547. w2.Material = "SmoothPlastic"
  548. w2.FormFactor = 'Custom'
  549. w2.BrickColor = BrickColor.new("Bright red")
  550. w2.Transparency = 0
  551. w2.Reflectance = 0
  552. w2.Material = "SmoothPlastic"
  553. w2.CanCollide = false
  554. nolines(w2)
  555. local sz = Vector3.new(0.2, width, len2)
  556. w2.Size = sz
  557. local sp = Instance.new("SpecialMesh", w2)
  558. sp.MeshType = "Wedge"
  559. sp.Scale = Vector3.new(0, 1, 1) * sz / w2.Size
  560. w2:BreakJoints()
  561. w2.Anchored = true
  562. w2.Parent = workspace
  563. w2.Transparency = 0.7
  564. fade(w2)
  565. w2.CFrame = maincf * CFrame.Angles(math.pi, math.pi, -math.pi / 2) * CFrame.new(0, width / 2, -len1 - len2 / 2)
  566. table.insert(list, w2)
  567. end
  568. return unpack(list)
  569. end
  570.  
  571.  
  572. -- Magic effects
  573. local magic = {}
  574. magic.stravant = function(brickcolor, cframe, x, y, z, x1, y1, z1, delay)
  575. local prt = part(3, workspace, 0, 0, brickcolor, "Effect", vt(0.5, 0.5, 0.5))
  576. prt.Anchored = true
  577. prt.CFrame = cframe * cf(x, y, z)
  578. local msh = mesh("SpecialMesh", prt, "FileMesh", "rbxassetid://168892363", vt(0, 0, 0), vt(x1, y1, z1))
  579. game:GetService("Debris"):AddItem(prt, 5)
  580. coroutine.resume(coroutine.create(function(Part, Mesh, ex, why, zee)
  581. local num = random()
  582. local num2 = random(-3, 2) + random()
  583. local numm = 0
  584. for i = 0, 1, delay * 2 do
  585. wait()
  586. Part.CFrame = cframe * euler(0, numm * num * 10, 0) * cf(ex, why, zee) * cf(-i * 10, num2, 0)
  587. Part.Transparency = i
  588. numm = numm + 0.01
  589. end
  590. Part.Parent = nil
  591. Mesh.Parent = nil
  592. end), prt, msh, x, y, z)
  593. end
  594. magic.block = function(brickcolor, cframe, x1, y1, z1, x3, y3, z3, delay, Type, par)
  595. local prt = part(3, par or workspace, 0, 0, brickcolor, "Effect", vt())
  596. prt.Anchored = true
  597. prt.CFrame = cframe
  598. local msh = mesh("BlockMesh", prt, "", "", vt(0, 0, 0), vt(x1, y1, z1))
  599. game:GetService("Debris"):AddItem(prt, 5)
  600. if Type == 1 or Type == nil then
  601. block1(prt, delay, x3, y3, z3, msh)
  602. elseif Type == 2 then
  603. block2(prt, delay, x3, y3, z3, msh)
  604. end
  605. end
  606. magic.circle = function(brickcolor, cframe, x1, y1, z1, x3, y3, z3, delay, par)
  607. local prt = part(3, par or workspace, 0, 0, brickcolor, "Effect", vt())
  608. prt.Anchored = true
  609. prt.CFrame = cframe
  610. local msh = mesh("SpecialMesh", prt, "Sphere", nil, vt(0, 0, 0), vt(x1, y1, z1))
  611. game:GetService("Debris"):AddItem(prt, 2)
  612. cyleffect(prt, delay, x3, y3, z3, msh)
  613. end
  614. magic.cylinder = function(brickcolor, cframe, x1, y1, z1, x3, y3, z3, delay)
  615. local prt = part(3, workspace, 0, 0, brickcolor, "Effect", vt())
  616. prt.Anchored = true
  617. prt.CFrame = cframe
  618. local msh = mesh("CylinderMesh", prt, "", "", vt(0, 0, 0), vt(x1, y1, z1))
  619. game:GetService("Debris"):AddItem(prt, 2)
  620. cyleffect(prt, delay, x3, y3, z3, msh)
  621. end
  622. magic.head = function(brickcolor, cframe, x1, y1, z1, x3, y3, z3, delay)
  623. local prt = part(3, workspace, 0, 0, brickcolor, "Effect", vt())
  624. prt.Anchored = true
  625. prt.CFrame = cframe
  626. local msh = mesh("SpecialMesh", prt, "Head", nil, vt(0, 0, 0), vt(x1, y1, z1))
  627. game:GetService("Debris"):AddItem(prt, 2)
  628. cyleffect(prt, delay, x3, y3, z3, msh)
  629. end
  630. magic.wave = function(brickcolor, cframe, x1, y1, z1, x3, y3, z3, delay)
  631. local prt = part(3, workspace, 0, 0, brickcolor, "Effect", vt())
  632. prt.Anchored = true
  633. prt.CFrame = cframe
  634. local msh = mesh("SpecialMesh", prt, "FileMesh", "http://www.roblox.com/asset/?id=20329976", vt(0, 0, 0), vt(x1, y1, z1))
  635. game:GetService("Debris"):AddItem(prt, 5)
  636. cyleffect(prt, delay, x3, y3, z3, msh)
  637. end
  638. magic.lightning = function(p0, p1, tym, ofs, col, th, tra, last, par)
  639. local magz = (p0 - p1).magnitude
  640. local curpos = p0
  641. local trz = {
  642. -ofs,
  643. ofs
  644. }
  645. for i = 1, tym do
  646. local li = Instance.new("Part", par or workspace)
  647. li.TopSurface = 0
  648. li.BottomSurface = 0
  649. li.Anchored = true
  650. li.Transparency = tra or 0.4
  651. li.BrickColor = BrickColor.new(col)
  652. li.Material = "Neon"
  653. li.formFactor = "Custom"
  654. li.CanCollide = false
  655. li.Size = Vector3.new(th, th, magz / tym)
  656. local ofz = Vector3.new(random(trz[1],trz[2]), random(trz[1],trz[2]), random(trz[1],trz[2]))
  657. local trolpos = CFrame.new(curpos, p1) * CFrame.new(0, 0, magz / tym).p + ofz
  658. if tym == i then
  659. local magz2 = (curpos - p1).magnitude
  660. li.Size = Vector3.new(th, th, magz2)
  661. li.CFrame = CFrame.new(curpos, p1) * CFrame.new(0, 0, -magz2 / 2)
  662. else
  663. li.CFrame = CFrame.new(curpos, trolpos) * CFrame.new(0, 0, magz / tym / 2)
  664. end
  665. curpos = li.CFrame * CFrame.new(0, 0, magz / tym / 2).p
  666. game.Debris:AddItem(li, last)
  667. end
  668. end
  669.  
  670.  
  671. -- Logic variables
  672. local equipped = false
  673. local attacking = false
  674.  
  675. -- Effect handling
  676. local charfx = Instance.new("Model", char)
  677. charfx.Name = "Effects"
  678. local toggles = {
  679. snow = false;
  680. lmagic = false;
  681. rmagic = false;
  682. canemagic = false;
  683. }
  684. local snowTick = 0
  685. local lmagicTick = 0
  686. local rmagicTick = 0
  687. local canemagicTick = 0
  688. local snowMeshes = {
  689. "http://www.roblox.com/asset?id=187687161";
  690. "http://www.roblox.com/asset?id=187687175";
  691. "http://www.roblox.com/asset?id=187687193";
  692.  
  693. }
  694.  
  695. -- Pose system
  696. local poses = {
  697. none = {
  698. larm = euler(0, 0, 0);
  699. rarm = euler(0, 0, 0);
  700. lleg = euler(0, 0, 0);
  701. rleg = euler(0, 0, 0);
  702. torso = euler(0, 0, 0);
  703. head = euler(0, 0, 0);
  704. cane = euler(0, 0, 0);
  705. }
  706. }
  707. local pose = "none"
  708. local posespeed = .1
  709. local newpose = function(name, larm, rarm, torso, head, lleg, rleg, cane)
  710. poses[name] = {
  711. larm = larm or rad();
  712. rarm = rarm or rad();
  713. lleg = lleg or rad();
  714. rleg = rleg or rad();
  715. torso = torso or rad();
  716. head = head or rad();
  717. cane = cane or rad();
  718. }
  719. end
  720. local setpose = function(name, speed)
  721. posespeed = speed or 1
  722. pose = name or "none"
  723. end
  724. game:GetService("RunService").RenderStepped:connect(function()
  725. local vel = (RP.Velocity*Vector3.new(1,0,1)).magnitude
  726. local yvel = RP.Velocity.y
  727. local hitfloor,posfloor=rayCast(RP.Position,(CFrame.new(RP.Position,RP.Position - Vector3.new(0,1,0))).lookVector,4,char)
  728. if yvel > 1 and hitfloor == nil and equipped and not attacking then
  729. setpose("jumping",.2)
  730. elseif yvel < -1 and hitfloor == nil and equipped and not attacking then
  731. setpose ("falling",.075)
  732. elseif vel < 1 and hitfloor ~= nil and equipped and not attacking then
  733. setpose("idle",.1)
  734. elseif vel > 2 and vel < 22 and hitfloor ~= nil and equipped and not attacking then
  735. setpose("walking",.1)
  736. end
  737. if poses[pose] ~= nil then
  738. local pose = poses[pose]
  739. LW.C0 = LW.C0:lerp(LSC0 * pose.larm, posespeed)
  740. RW.C0 = RW.C0:lerp(RSC0 * pose.rarm, posespeed)
  741. LH.C0 = LH.C0:lerp(LHC0 * pose.lleg, posespeed)
  742. RH.C0 = RH.C0:lerp(RHC0 * pose.rleg, posespeed)
  743. RJ.C0 = RJ.C0:lerp(RJC0 * pose.torso, posespeed)
  744. neck.C0 = neck.C0:lerp(neckC0 * pose.head, posespeed)
  745. caneweld.C0 = caneweld.C0:lerp(caneweldC0 * pose.cane, posespeed)
  746. end
  747. if toggles.snow == true then
  748. if snowTick % 15 == 0 then
  749. local p = Instance.new("Part")
  750. local m = Instance.new("SpecialMesh", p)
  751. m.MeshId = snowMeshes[math.random(1, #snowMeshes)]
  752. m.Scale = Vector3.new(2,2,2)
  753. local q = Instance.new("BodyVelocity")
  754. p.BrickColor = BrickColor.new("White")
  755. p.Parent = charfx
  756. p.Shape = 1
  757. p.Size = Vector3.new(.5, .5, .5)
  758. p.Transparency = .3
  759. p.Locked = true
  760. p.Anchored = false
  761. p.CanCollide = false
  762. p.formFactor = "Plate"
  763. p.CFrame = torso.CFrame * cf(Vector3.new((random(-75, 75)),50,(random(-75,75)))) * randomRot()
  764. q.velocity = Vector3.new(0, -10, 0)
  765. q.Parent = p
  766. p.Touched:connect(function()
  767. p:destroy()
  768. end)
  769. end
  770. snowTick = snowTick + 1
  771. end
  772. if toggles.lmagic then
  773. if lmagicTick % 15 == 0 then
  774. magic.block(BrickColor.new("Institutional white"),larm.CFrame*cf(0,-1,0),1,1,1,.5,.5,.5,.065,nil,charfx)
  775. end
  776. lmagicTick = lmagicTick + 1
  777. end
  778. if toggles.rmagic then
  779. if rmagicTick % 15 == 0 then
  780. magic.block(BrickColor.new("Institutional white"),rarm.CFrame*cf(0,-1,0),1,1,1,.5,.5,.5,.065,nil,charfx)
  781. end
  782. rmagicTick = rmagicTick + 1
  783. end
  784. if toggles.canemagic then
  785. if canemagicTick % 15 == 0 then
  786. magic.block(BrickColor.new("Institutional white"),cane.CFrame*caneEnd,1,1,1,.5,.5,.5,.065,nil,charfx)
  787. end
  788. canemagicTick = canemagicTick + 1
  789. end
  790. end)
  791.  
  792.  
  793. -- Weapon setup
  794. local bin = Instance.new("HopperBin",backpack)
  795. bin.Name = "Cane"
  796. script.Parent = bin
  797.  
  798. -- Weapon poses
  799. newpose("idle", rad(-5,5,0), rad(0,0,50), rad(0,-2,-15), rad(0,-3,15), rad(0,15,0), rad(0,15,0), rad(90,-45,170)*CFrame.new(0,-1,-1.5))
  800. newpose("jumping", rad(-20, 0, -10), rad(-20, 0, 10), rad(-10, 0, 0), rad(0, 0, 0), rad(0, 0, 15), rad(0, 0, 0)*CFrame.new(.35,.35,0))
  801. newpose("falling", rad(0, 0, -50), rad(0, 0, 50), rad(0, 0, 0), rad(20, 0, 0), rad(0, 0, 0), rad(0, 0, 0)*CFrame.new(.15,.15,0))
  802. newpose("walking", rad(-5,5,-15), rad(-20,0,20), rad(5,0,0), rad(0,0,0), rad(0,0,0), rad(0,0,0))
  803.  
  804. -- Attack poses
  805. newpose("larmcharge", rad(0,-15,-135), rad(0,0,50), rad(0,-2,-15), rad(-15,-15,50), rad(0,15,0), rad(0,15,0), rad(90,-45,170)*CFrame.new(0,-1,-1.5))
  806. newpose("canecharge", rad(45,0,30), rad(0,0,150), rad(0,0,-35), rad(-20,0,0), rad(0,35,0), rad(0,35,0), rad(90,-135,170)*CFrame.new(0,-1,-1.5))
  807. newpose("clickattack1_1", rad(20,0,15), rad(0,-15,125), rad(0,-2,-35), rad(0,-3,35), rad(0,35,0), rad(0,35,0), rad(90,-165,180)*CFrame.new(0,-1,-1.5))
  808. newpose("clickattack1_2", rad(-20,0,-15), rad(0,100,65), rad(0,-2,45), rad(10,-10,-25), rad(0,-45,0), rad(0,-45,0), rad(90,-110,180)*CFrame.new(0,-1,-1.5))
  809. newpose("clickattack2_1", rad(-45,0,-45), rad(0,150,65), rad(0,-2,65), rad(10,-10,-45), rad(0,-65,0), rad(0,-65,0), rad(90,-135,180)*CFrame.new(0,-1,-1.5))
  810. newpose("clickattack2_2", rad(-15,0,-60), rad(0,-15,70), rad(0,-2,-35), rad(0,-3,35), rad(0,35,0), rad(0,35,0), rad(90,-110,180)*CFrame.new(0,-1,-1.5))
  811. newpose("clickattack3_1", rad(-15,0,-60), rad(0,-15,125), rad(0,-2,-45), rad(0,-3,45), rad(0,45,0), rad(0,45,0), rad(90,-165,180)*CFrame.new(0,-1,-1.5))
  812. newpose("clickattack3_2", rad(-20,0,-75), rad(-90,0,110), rad(0,0,75), rad(10,-10,-60), rad(0,-80,30), rad(0,-80,0), rad(90,-90,180)*CFrame.new(0,-1,-1.5))
  813. newpose("clickattack4_1", rad(0,0,-90), rad(0,0,125), rad(0,0,-90), rad(0,0,90), rad(0,35,0), rad(0,35,0), rad(90,-165,180)*CFrame.new(0,-1,-1.5))
  814. newpose("clickattack4_2", rad(0,0,-135), rad(0,0,125), rad(0,0,-90), rad(0,0,90), rad(0,35,0), rad(0,35,0), rad(90,-165,180)*CFrame.new(0,-1,-1.5))
  815.  
  816. -- Weapon usage (edit to liking)
  817. local equip = function()
  818. equipped = true
  819. if attacking then
  820. repeat
  821. wait()
  822. until not attacking
  823. end
  824. attacking = true
  825. if not equipped then
  826. attacking = false
  827. return
  828. end
  829. LW.Part1 = larm
  830. RW.Part1 = rarm
  831. LS.Part1 = nil
  832. RS.Part1 = nil
  833. attacking = false
  834. setpose("idle", .085)
  835. end
  836. local unequip = function()
  837. equipped = false
  838. if attacking then
  839. repeat
  840. wait()
  841. until not attacking
  842. end
  843. if equipped then
  844. return
  845. end
  846. setpose("none", .1)
  847. wait(.65)
  848. if equipped then
  849. return
  850. end
  851. LS.Part1 = larm
  852. RS.Part1 = rarm
  853. LW.Part1 = nil
  854. RW.Part1 = nil
  855. end
  856. local keypress = function(key)
  857. if attacking or not equipped then return end
  858. if key == "q" then
  859. attacking = true
  860. print("q")
  861. hum.WalkSpeed = 0
  862. setpose("larmcharge", .1)
  863. wait(.3)
  864. toggles.lmagic = true
  865. sound(sounds.chargepulse, larm, .75, .8)
  866. wait(1.5)
  867. toggles.lmagic = false
  868. magic.circle(BrickColor.new("Institutional white"), larm.CFrame*CFrame.new(0,-1,0), 1, 1, 1, 1.2, 1.2, 1.2, .04, charfx)
  869. sound(sounds.bewm, cane, .9, .6)
  870. toggles.snow = not toggles.snow
  871. print("snow "..(toggles.snow and "yes" or "no"))
  872. wait(.5)
  873. hum.WalkSpeed = 16
  874. attacking = false
  875. elseif key == "x" then
  876. attacking = true
  877. print("x")
  878. hum.WalkSpeed = 12
  879. toggles.canemagic = true
  880. setpose("canecharge", .1)
  881. sound(sounds.charge,char.Torso,.5,1.1)
  882. wait(.5)
  883. setpose("clickattack3_2", .175)
  884. wait(.3)
  885. magic.circle(BrickColor.new("Institutional white"), cane.CFrame*caneEnd, .2, .2, .3, 6, 6, 0, .075)
  886. hum.WalkSpeed = 0
  887. sound(sounds.sharpblast,cane,1,.35)
  888. print("pewwwwwww")
  889. for i = 1, 50 do
  890. local prt,hit = rayCast(cane.CFrame*caneEnd.p,((cane.CFrame*caneEnd).p - (cane.CFrame*(caneEnd*CFrame.new(0,0,1))).p).unit, 100, char)
  891. magic.lightning((cane.CFrame*caneEnd).p, hit, 20, 1, "Institutional white", .1, .2, .15, charfx)
  892. sound(sounds.zap,cane,random(.75,1),random(.75,1.25))
  893. if prt and prt.Parent:FindFirstChild("Humanoid") then
  894. damage(prt, 35, 50, 2, "Knockdown", RP, .5, 1, random(3, 10), nil, true)
  895. sound(sounds.zap,prt,random(.75,1),random(.75,1.25))
  896. sound(sounds.sharpblast,prt,.3,.5)
  897. sound(sounds.bewm,prt,1,.75)
  898. end
  899. wait(.02)
  900. end
  901. toggles.canemagic = false
  902. hum.WalkSpeed = 16
  903. attacking = false
  904. end
  905. end
  906. local combo = 0
  907. local clicked = function(hit)
  908. if attacking or not equipped then return end
  909. if combo == 0 then
  910. attacking = true
  911. combo = combo + 1
  912. print("swing"..combo)
  913. setpose("clickattack1_1", .165)
  914. wait(.125)
  915. local dam1 = cane.Touched:connect(function(hit)
  916. if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
  917. damage(hit, 10, 15, .25, "Normal", RP, .5, 1, random(3, 10), nil, true)
  918. end
  919. end)
  920. local dam2 = rarm.Touched:connect(function(hit)
  921. if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
  922. damage(hit, 10, 15, .25, "Normal", RP, .5, 1, random(3, 10), nil, true)
  923. end
  924. end)
  925. setpose("clickattack1_2", .185)
  926. sound(sounds.swing,cane,.5,random(1,1.5))
  927. wait(.35)
  928. dam1:disconnect()
  929. dam2:disconnect()
  930. attacking = false
  931. wait(1)
  932. if combo == 1 then
  933. combo = 0
  934. print("ded")
  935. end
  936. elseif combo == 1 then
  937. attacking = true
  938. combo = combo + 1
  939. print("swing"..combo)
  940. setpose("clickattack2_1", .15)
  941. wait(.125)
  942. local dam1 = cane.Touched:connect(function(hit)
  943. if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
  944. damage(hit, 10, 15, .25, "Normal", RP, .5, 1, random(3, 10), nil, true)
  945. end
  946. end)
  947. local dam2 = rarm.Touched:connect(function(hit)
  948. if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
  949. damage(hit, 10, 15, .25, "Normal", RP, .5, 1, random(3, 10), nil, true)
  950. end
  951. end)
  952. setpose("clickattack2_2", .14)
  953. sound(sounds.swing,cane,.5,random(1,1.5))
  954. for i = 1, 5 do
  955. torso.Velocity = RP.CFrame.lookVector * 45
  956. wait()
  957. end
  958. wait(.25)
  959. dam1:disconnect()
  960. dam2:disconnect()
  961. attacking = false
  962. wait(1)
  963. if combo == 2 then
  964. combo = 0
  965. print("ded")
  966. end
  967. elseif combo == 2 then
  968. attacking = true
  969. combo = combo + 1
  970. print("swing"..combo)
  971. setpose("clickattack3_1", .15)
  972. wait(.2)
  973. local dam1 = cane.Touched:connect(function(hit)
  974. if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
  975. damage(hit, 10, 15, .25, "Normal", RP, .5, 1, random(3, 10), nil, true)
  976. end
  977. end)
  978. local dam2 = rarm.Touched:connect(function(hit)
  979. if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= char then
  980. damage(hit, 10, 15, .25, "Normal", RP, .5, 1, random(3, 10), nil, true)
  981. end
  982. end)
  983. setpose("clickattack3_2", .2)
  984. sound(sounds.swing,cane,.5,random(.5,1))
  985. for i = 1, 5 do
  986. torso.Velocity = RP.CFrame.lookVector * 55
  987. wait()
  988. end
  989. wait(.3)
  990. dam1:disconnect()
  991. dam2:disconnect()
  992. attacking = false
  993. wait(.5)
  994. if combo == 3 then
  995. combo = 0
  996. print("ded")
  997. end
  998. elseif combo == 3 then
  999. attacking = true
  1000. combo = combo + 1
  1001. print("swing"..combo)
  1002. setpose("clickattack4_1", .18)
  1003. sound(sounds.swing,cane,.5,random(1,1.5))
  1004. wait(.3)
  1005. local bewmcf = larm.CFrame*cf(0,-3,0)
  1006. local bewmrange = 7.5
  1007. for i = 1, 2 do
  1008. magic.block(BrickColor.new("Institutional white"), bewmcf, 1, 1, 1, 2, 2, 2, .075)
  1009. end
  1010. for _,v in pairs(game.Workspace:GetChildren()) do
  1011. if v:FindFirstChild("Torso") and v.Torso:IsA("Part") then
  1012. local vtor = v.Torso
  1013. local dist = (bewmcf.p - vtor.Position).magnitude
  1014. if dist <= bewmrange then
  1015. damage(vtor, 20, 30, .5, "Normal", RP, .5, 1, random(3, 10), nil, true)
  1016. end
  1017. end
  1018. end
  1019. sound(sounds.bewm,rarm,1,random(1,2))
  1020. print("bewm")
  1021. setpose("clickattack4_2", .165)
  1022. wait(.175)
  1023. attacking = false
  1024. --wait(.5)
  1025. if combo == 4 then
  1026. combo = 0
  1027. print("ded")
  1028. end
  1029. end
  1030. end
  1031. bin.Selected:connect(equip)
  1032. bin.Deselected:connect(unequip)
  1033. mouse.Button1Down:connect(clicked)
  1034. mouse.KeyDown:connect(keypress)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement