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