View difference between Paste ID: HtdzDSjE and PbkB8LRD
SHOW: | | - or go back to the newest paste.
1
local isScriptNil = false
2
3
local PlrName = "xExplicitCass"
4
local Plrs = game:GetService("Players")
5
local RunService = game:GetService("RunService")
6
local Content = game:GetService("ContentProvider")
7
local LP = Plrs.LocalPlayer
8
local Char = LP.Character
9
local PlrGui = LP.PlayerGui
10
local Backpack = LP.Backpack
11
local Mouse = LP:GetMouse()
12
13
local Camera = Workspace.CurrentCamera
14
local LastCamCF = Camera.CoordinateFrame
15
local AnimJoints = {}
16
local Cons = {}
17
local mDown = false
18
local Multi = false
19
local Grabbing = false
20
local Current = {}
21
local Alpha = 1
22
local LightNum = 1
23
24
Current.Part = nil
25
Current.BP = nil
26
Current.BA = nil
27
Current.Mass = nil
28
29
local LastPart = nil
30
31
local Head = Char["Head"]
32
local Torso = Char["Torso"]
33
local Humanoid = Char["Humanoid"]
34
local LA = Char["Left Arm"]
35
local RA = Char["Right Arm"]
36
local LL = Char["Left Leg"]
37
local RL = Char["Right Leg"]
38
39
local LS, RS;
40
41
local OrigLS = Torso["Left Shoulder"]
42
local OrigRS = Torso["Right Shoulder"]
43
44
for _,v in pairs(Char:GetChildren()) do
45
	if v.Name == ModID then
46
		v:Destroy()
47
	end
48
end
49
50
for _,v in pairs(PlrGui:GetChildren()) do
51
	if v.Name == "PadsGui" then
52
		v:Destroy()
53
	end
54
end
55
56
local ModID = "Pads"
57
local Objects = {}
58
local Grav = 196.2
59
60
local sin=math.sin
61
local cos=math.cos
62
local max=math.max
63
local min=math.min
64
local atan2=math.atan2
65
local random=math.random
66
local tau = 2 * math.pi
67
68
local BodyObjects = {
69
	["BodyVelocity"] = true;
70
	["BodyAngularVelocity"] = true;
71
	["BodyForce"] = true;
72
	["BodyThrust"] = true;
73
	["BodyPosition"] = true;
74
	["RocketPropulsion"] = true;
75
}
76
77
if LP.Name == PlrName and isScriptNil then
78
	script.Parent = nil
79
end
80
81
LP.CameraMode = "Classic"
82
83
local Assets = {
84
}
85
86
local LS0, LS1 = OrigLS.C0, OrigLS.C1
87
local RS0, RS1 = OrigRS.C0, OrigRS.C1
88
89
for i,v in pairs(Assets) do
90
	local ID = tostring(Assets[i])
91
	Assets[i] = "http://www.roblox.com/asset/?id=" .. ID
92
	Content:Preload("http://www.roblox.com/asset/?id=" .. ID)
93
end
94
95
function QuaternionFromCFrame(cf)
96
	local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components();
97
	local trace = m00 + m11 + m22 if trace > 0 then 
98
		local s = math.sqrt(1 + trace);
99
		local recip = 0.5/s;
100
		return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5;
101
	else 
102
		local i = 0;
103
		if m11 > m00 then 
104
			i = 1;
105
		end;
106
		if m22 > (i == 0 and m00 or m11) then
107
			i = 2 end if i == 0 then
108
			local s = math.sqrt(m00-m11-m22+1);
109
			local recip = 0.5/s return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip; 
110
		elseif i == 1 then
111
			local s = math.sqrt(m11-m22-m00+1);
112
			local recip = 0.5/s;
113
			return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip ;
114
		elseif i == 2 then
115
			local s = math.sqrt(m22-m00-m11+1);
116
			local recip = 0.5/s;
117
			return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip;
118
		end;
119
	end; 
120
end;
121
122
function QuaternionToCFrame(px, py, pz, x, y, z, w)
123
	local xs, ys, zs = x + x, y + y, z + z;
124
	local wx, wy, wz = w*xs, w*ys, w*zs;
125
	local xx = x*xs;
126
	local xy = x*ys;
127
	local xz = x*zs;
128
	local yy = y*ys;
129
	local yz = y*zs;
130
	local zz = z*zs;
131
	return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy)) 
132
end;
133
134
function QuaternionSlerp(a, b, t)
135
	local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4];
136
	local startInterp, finishInterp; 
137
	if cosTheta >= 0.0001 then
138
		if (1 - cosTheta) > 0.0001 then
139
			local theta = math.acos(cosTheta);
140
			local invSinTheta = 1/math.sin(theta);
141
			startInterp = math.sin((1-t)*theta)*invSinTheta;
142
			finishInterp = math.sin(t*theta)*invSinTheta;
143
		else
144
			startInterp = 1-t finishInterp = t;
145
		end;
146
	else 
147
		if (1+cosTheta) > 0.0001 then
148
			local theta = math.acos(-cosTheta);
149
			local invSinTheta = 1/math.sin(theta);
150
			startInterp = math.sin((t-1)*theta)*invSinTheta;
151
			finishInterp = math.sin(t*theta)*invSinTheta;
152
		else startInterp = t-1 finishInterp = t;
153
		end;
154
	end;
155
	return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp;
156
end;
157
158
function CLerp(a,b,t)
159
	local qa={QuaternionFromCFrame(a)};
160
	local qb={QuaternionFromCFrame(b)};
161
	local ax,ay,az=a.x,a.y,a.z;
162
	local bx,by,bz=b.x,b.y,b.z;
163
	local _t=1-t;
164
	return QuaternionToCFrame(_t*ax+t*bx,_t*ay+t*by,_t*az+t*bz,QuaternionSlerp(qa, qb, t));
165
end
166
167
function GetWeld(weld) 
168
	local obj 
169
	for i, v in pairs(AnimJoints) do 
170
		if v[1] == weld then 
171
			obj = v 
172
			break 
173
		end 
174
	end 
175
	if not obj then 
176
		obj = {weld,NV} 
177
		table.insert(AnimJoints,obj) 
178
	end 
179
	return weld.C0.p, obj[2] 
180
end 
181
182
function SetWeld(weld, i, loops, origpos, origangle, nextpos, nextangle, override, overrideLower, smooth) 
183
	smooth = smooth or 1 
184
	local obj 
185
	for i, v in pairs(AnimJoints) do 
186
		if v[1] == weld then 
187
			obj = v 
188
			break 
189
		end 
190
	end 
191
	if not obj then 
192
		obj = {weld,NV} 
193
		table.insert(AnimJoints,obj) 
194
	end 
195
	
196
	local perc = (smooth == 1 and math.sin((math.pi/2)/loops*i)) or i/loops 
197
	
198
	local tox,toy,toz = 0,0,0 
199
	tox = math.abs(origangle.x - nextangle.x) *perc 
200
	toy = math.abs(origangle.y - nextangle.y) *perc 
201
	toz = math.abs(origangle.z - nextangle.z) *perc 
202
	tox = ((origangle.x > nextangle.x and -tox) or tox)
203
	toy = ((origangle.y > nextangle.y and -toy) or toy)
204
	toz = ((origangle.z > nextangle.z and -toz) or toz)
205
	
206
	local tox2,toy2,toz2 = 0,0,0 
207
	tox2 = math.abs(origpos.x - nextpos.x) *perc 
208
	toy2 = math.abs(origpos.y - nextpos.y) *perc 
209
	toz2 = math.abs(origpos.z - nextpos.z) *perc 
210
	tox2 = (origpos.x > nextpos.x and -tox2) or tox2 
211
	toy2 = (origpos.y > nextpos.y and -toy2) or toy2 
212
	toz2 = (origpos.z > nextpos.z and -toz2) or toz2 
213
	
214
	obj[2] = Vector3.new(origangle.x + tox, origangle.y + toy, origangle.z + toz) 
215
	weld.C0 = CFrame.new(origpos.x + tox2,origpos.y + toy2,origpos.z + toz2) * CFrame.Angles(origangle.x + tox,origangle.y + toy,origangle.z + toz) 
216
end 
217
218
function RotateCamera(x, y)
219
	Camera.CoordinateFrame = CFrame.new(Camera.Focus.p) * (Camera.CoordinateFrame - Camera.CoordinateFrame.p) * CFrame.Angles(x, y, 0) * CFrame.new(0, 0, (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude)
220
end
221
222
function GetAngles(cf)
223
	local lv = cf.lookVector
224
	return -math.asin(lv.y), math.atan2(lv.x, -lv.z)
225
end
226
227
local LastCamCF = Camera.CoordinateFrame
228
229
function Look()
230
	if AlphaOn == true then
231
		local x, y = GetAngles(LastCamCF:toObjectSpace(Camera.CoordinateFrame))
232
		Camera.CoordinateFrame = LastCamCF
233
		RotateCamera(x * -(Alpha), y * -(Alpha))
234
		LastCamCF = Camera.CoordinateFrame
235
	end
236
end
237
238
function Cor(Func)
239
	local Ok, Err = coroutine.resume(coroutine.create(Func))
240
	if not Ok then
241
		print(Err)
242
	end
243
end
244
245
function Cor2(Func)
246
	local Ok, Err = ypcall(Func)
247
	if not Ok then
248
		print(Err)
249
	end
250
end
251
252
function MakePads()
253
	-- 1 - VTelekinesis
254
	P1 = Instance.new("Model")
255
	P1.Name = ModID
256
257
	-- 2 - RBase
258
	P2 = Instance.new("Part")
259
	P2.CFrame = CFrame.new(Vector3.new(21.100008, 1.95000589, 11.899971)) * CFrame.Angles(-0, 0, -0)
260
	P2.FormFactor = Enum.FormFactor.Custom
261
	P2.Size = Vector3.new(0.799999952, 0.200000003, 0.800000012)
262
	P2.Anchored = true
263-
	P2.BrickColor = BrickColor.new("White")
263+
	P2.BrickColor = BrickColor.new("Lime green")
264
	P2.Friction = 0.30000001192093
265
	P2.Shape = Enum.PartType.Block
266
	P2.Name = "RBase"
267
	P2.Parent = P1
268
    P2.Transparency = 1
269
	-- 3 - Mesh
270
	P3 = Instance.new("CylinderMesh")
271
	P3.Scale = Vector3.new(1, 0.5, 1)
272
	P3.Parent = P2
273
274
	-- 4 - LBase
275
	P4 = Instance.new("Part")
276
	P4.CFrame = CFrame.new(Vector3.new(18.100008, 1.95000589, 11.899971)) * CFrame.Angles(-0, 0, -0)
277
	P4.FormFactor = Enum.FormFactor.Custom
278
	P4.Size = Vector3.new(0.799999952, 0.200000003, 0.800000012)
279
	P4.Anchored = true
280-
	P4.BrickColor = BrickColor.new("White")
280+
	P4.BrickColor = BrickColor.new("Lime green")
281
	P4.Friction = 0.30000001192093
282
	P4.Shape = Enum.PartType.Block
283
	P4.Name = "LBase"
284
	P4.Parent = P1
285
    P4.Transparency = 1
286
	-- 5 - Mesh
287
	P5 = Instance.new("CylinderMesh")
288
	P5.Scale = Vector3.new(1, 0.5, 1)
289
	P5.Parent = P4
290
291
	-- 7 - Mesh
292
	P7 = Instance.new("CylinderMesh")
293
	P7.Scale = Vector3.new(1, 0.5, 1)
294
	P7.Parent = P6
295
296
	
297
298
	-- 9 - Mesh
299
	P9 = Instance.new("CylinderMesh")
300
	P9.Scale = Vector3.new(1, 0.5, 1)
301
	P9.Parent = P8
302
303
	
304
305
	-- 11 - Mesh
306
	P11 = Instance.new("CylinderMesh")
307
	P11.Scale = Vector3.new(1, 0.5, 1)
308
	P11.Parent = P10
309
310
	
311
	-- 13 - Mesh
312
	P13 = Instance.new("CylinderMesh")
313
	P13.Scale = Vector3.new(1, 0.5, 1)
314
	P13.Parent = P12
315
316
317
	-- 15 - Mesh
318
	P15 = Instance.new("CylinderMesh")
319
	P15.Scale = Vector3.new(1, 0.5, 1)
320
	P15.Parent = P14
321
322
	-- 17 - Mesh
323
	P17 = Instance.new("CylinderMesh")
324
	P17.Scale = Vector3.new(1, 0.5, 1)
325
	P17.Parent = P16
326
327
	P1.Parent = LP.Character
328
	P1:MakeJoints()
329
	return P1
330
end
331
332
weldModel = function(model, unanchor, rooty)
333
	local parts = {}
334
	local function recurse(object)
335
		if object:IsA("BasePart") then
336
			table.insert(parts, object)
337
		end
338
		for _,child in pairs(object:GetChildren()) do
339
			recurse(child)
340
		end
341
	end
342
	recurse(model)
343
	
344
	local rootPart = rooty or parts[1]
345
	for _, part in pairs(parts) do
346
		local cframe = rootPart.CFrame:toObjectSpace(part.CFrame)
347
		local weld = Instance.new("Weld")
348
		weld.Part0 = rootPart
349
		weld.Part1 = part
350
		weld.C0 = cframe
351
		weld.Parent = rootPart
352
	end
353
	
354
	if unanchor then
355
		for _, part in pairs(parts) do
356
			part.Anchored = false
357
			part.CanCollide = false
358
		end
359
	end
360
end
361
362
weldItem = function(rootPart, Item, TheC0, unanchor, ParentItem)
363
	local cframe = TheC0 or rootPart.CFrame:toObjectSpace(Item.CFrame)
364
	local weld = Instance.new("Weld")
365
	weld.Name = "Weld"
366
	weld.Part0 = rootPart
367
	weld.Part1 = Item
368
	weld.C0 = cframe
369
	weld.Parent = ParentItem and Item or rootPart
370
	
371
	if unanchor then
372
		Item.Anchored = false
373
	end
374
	return weld, cframe
375
end
376
377
scaleModel = function(model, scale)
378
	local parts = {}
379
	local function recurse(object)
380
		if object:IsA("BasePart") then
381
			table.insert(parts, object)
382
		end
383
		for _,child in pairs(object:GetChildren()) do
384
			recurse(child)
385
		end
386
	end
387
	recurse(model)
388
	
389
	local top, bottom, left, right, back, front
390
	for _, part in pairs(parts) do
391
		if top == nil or top < part.Position.y then			top = part.Position.y end
392
		if bottom == nil or bottom > part.Position.y then	bottom = part.Position.y end
393
		if left == nil or left > part.Position.x then		left = part.Position.x end
394
		if right == nil or right < part.Position.x then		right = part.Position.x end
395
		if back == nil or back > part.Position.z then		back = part.Position.z end
396
		if front == nil or front < part.Position.z then		front = part.Position.z end
397
	end
398
	
399
	local middle = Vector3.new( left+right, top+bottom, back+front )/2
400
	local minSize = Vector3.new(0.2, 0.2, 0.2)
401
	
402
	for _, part in pairs(parts) do
403
		local foo = part.CFrame.p - middle
404
		local rotation = part.CFrame - part.CFrame.p
405
		local newSize = part.Size*scale
406
		part.FormFactor = "Custom"
407
		part.Size = newSize
408
		part.CFrame = CFrame.new( middle + foo*scale ) * rotation
409
		
410
		if newSize.x < minSize.x or newSize.y < minSize.y or newSize.z < minSize.z then
411
			local mesh
412
			for _, child in pairs(part:GetChildren()) do
413
				if child:IsA("DataModelMesh") then
414
					mesh = child
415
					break
416
				end
417
			end
418
			
419
			if mesh == nil then
420
				mesh = Instance.new("BlockMesh", part)
421
			end
422
			
423
			local oScale = mesh.Scale
424
			local newScale = newSize/minSize * oScale
425
			if 0.2 < newSize.x then newScale = Vector3.new(1 * oScale.x, newScale.y, newScale.z) end
426
			if 0.2 < newSize.y then newScale = Vector3.new(newScale.x, 1 * oScale.y, newScale.z) end
427
			if 0.2 < newSize.z then newScale = Vector3.new(newScale.x, newScale.y, 1 * oScale.z) end
428
			
429
			mesh.Scale = newScale
430
		end
431
	end
432
end
433
434
function getMass(Obj, Total)
435
	local newTotal = Total
436
	local returnTotal = 0
437
	
438
	if Obj:IsA("BasePart") then
439
		newTotal = newTotal + Objects[Obj]
440
	elseif BodyObjects[Obj.ClassName] then
441
		Obj:Destroy()
442
	end
443
	
444
	if Obj:GetChildren() and #Obj:GetChildren() > 0 then
445
		for _,v in pairs(Obj:GetChildren()) do
446
			returnTotal = returnTotal + getMass(v, newTotal)
447
		end
448
	else
449
		returnTotal = newTotal
450
	end
451
	
452
	return returnTotal
453
end
454
455
function getTargFromCurrent()
456
	local Current = Current.Part
457
	if Current:IsA("BasePart") then
458
		return Current
459
	elseif Current:findFirstChild("Torso") then
460
		return Current.Torso
461
	else
462
		for _,v in pairs(Current:GetChildren()) do
463
			if v:IsA("BasePart") then
464
				return v
465
			end
466
		end
467
	end
468
end
469
470
function Fire(Part, Vec, Inv)
471
	pcall(function()
472
		Current.BP:Destroy()
473
		Current.BP = nil
474
	end)
475
	pcall(function()
476
		Current.BA:Destroy()
477
		Current.BA = nil
478
	end)
479
	pcall(function()
480
		if Inv then
481
			Part.Velocity = -((Vec - Torso.Position).unit * Grav * 1.1)
482
		else
483
			Part.Velocity = ((Vec - Camera.CoordinateFrame.p).unit * Grav * 1.1)
484
		end
485
		Current.Mass = nil
486
	end)
487
	Reset()
488
end
489
490
function Reset()
491
	LS.Parent = nil
492
	RS.Parent = nil
493
	
494
	OrigLS.Parent = Torso
495
	OrigRS.Parent = Torso
496
	
497
	OrigLS.C0 = LS0
498
	OrigRS.C0 = RS0
499
end
500
501
function Start()
502
	Cor(function()
503
		repeat wait(1/30) until LP.Character and LP.Character.Parent == Workspace and LP.Character:findFirstChild("Torso")
504
		Char = LP.Character
505
		PlrGui = LP.PlayerGui
506
		Backpack = LP.Backpack
507
		Mouse = LP:GetMouse()
508
		
509
		for _,v in pairs(Cons) do
510
			v:disconnect()
511
		end
512
		Cons = {}
513
514
		Camera = Workspace.CurrentCamera
515
		LastCamCF = Camera.CoordinateFrame
516
		AnimJoints = {}
517
		mDown = false
518
		Multi = false
519
		Grabbing = false
520
		Current = {}
521
		Alpha = 1
522
523
		Head = Char["Head"]
524
		Torso = Char["Torso"]
525
		Humanoid = Char["Humanoid"]
526
		LA = Char["Left Arm"]
527
		RA = Char["Right Arm"]
528
		LL = Char["Left Leg"]
529
		RL = Char["Right Leg"]
530
		
531
		OrigLS = Torso["Left Shoulder"]
532
		OrigRS = Torso["Right Shoulder"]
533
534
		for _,v in pairs(Char:GetChildren()) do
535
			if v.Name == ModID then
536
				v:Destroy()
537
			end
538
		end
539
540
		for _,v in pairs(PlrGui:GetChildren()) do
541
			if v.Name == "PadsGui" then
542
				v:Destroy()
543
			end
544
		end
545
		
546
		LS = Instance.new("Weld")
547
		RS = Instance.new("Weld")
548
549
		LS.Name = OrigLS.Name
550
		LS.Part0 = Torso
551
		LS.Part1 = LA
552
		LS.C0 = LS0
553
		LS.C1 = CFrame.new(0, 0.5, 0,  1, 0, 0,  0, 0, 1,  0, -1, 0)
554
555
		RS.Name = OrigRS.Name
556
		RS.Part0 = Torso
557
		RS.Part1 = RA
558
		RS.C0 = RS0
559
		RS.C1 = CFrame.new(0, 0.5, 0,  1, 0, 0,  0, 0, 1,  0, -1, 0)
560
561
		local Pads = MakePads()
562
		local LPad = Pads.LBase
563
		local RPad = Pads.RBase
564
565
		weldModel(LPad, true, LPad)
566
		weldModel(RPad, true, RPad)
567
568
		local GripWeldL = Instance.new("Weld")
569
		GripWeldL.Name = "GripWeldL"
570
		GripWeldL.Part0 = LA
571
		GripWeldL.Part1 = LPad
572
		GripWeldL.C0 = CFrame.new(0, -1.05, 0) * CFrame.Angles(0, math.rad(180), 0)
573
		GripWeldL.Parent = LA
574
575
		local GripWeldR = Instance.new("Weld")
576
		GripWeldR.Name = "GripWeldR"
577
		GripWeldR.Part0 = RA
578
		GripWeldR.Part1 = RPad
579
		GripWeldR.C0 = CFrame.new(0, -1.05, 0) * CFrame.Angles(0, math.rad(180), 0)
580
		GripWeldR.Parent = RA
581
		
582
		local isParts = false
583
584
		table.insert(Cons, Mouse.KeyDown:connect(function(Key)
585
			Key = Key:lower()
586
			if Key == "z" then
587
				--Stuff
588
			elseif Key == "f" then
589
				local Current = Current.Part
590
				if Current and Current.Parent ~= nil and not Multi then
591
					Current:BreakJoints()
592
				end
593
			elseif Key == "q" then
594
				if isParts then
595
					isParts = false
596
					for _,v in pairs(Workspace:GetChildren()) do
597
						if v.Name == "MyPartV" and v:IsA("BasePart") then
598
							v:Destroy()
599
						end
600
					end
601
				else
602
					isParts = true
603
					for i = 1, 50 do
604
						local Part = Instance.new("Part")
605-
						Part.Color = Color3.new(math.random(), math.random(), math.random())
605+
						Part.Color = Color3.new('Lime green')
606
						Part.Transparency = 0
607-
						Part.Size = Vector3.new(math.random(1, 3), math.random(1, 3), math.random(1, 3))
607+
						Part.Size = Vector3.new(math.random(20, 30))
608
						Part.Archivable = true
609
						Part.CanCollide = false
610-
						Part.Material = "Neon"
610+
						Part.Material = "Grass"
611
						Part.Locked = false
612
						Part.CFrame = Torso.CFrame * CFrame.new(math.random(-15, 15), -1, math.random(-15, 15))
613
						Part.Anchored = true
614
						Part.Name = "MyPartV"
615
						Part.TopSurface = "Smooth"
616
						Part.BottomSurface = "Smooth"
617
						Part.Parent = Workspace
618
					end
619
				end
620-
			elseif Key == "e" then
620+
621-
				local Targ;
621+
622-
				if Current.Part and Current.Part ~= nil then
622+
623-
					Targ = getTargFromCurrent()
623+
624
					Ex.BlastRadius = 16
625-
					Targ = LastPart
625+
626
				end
627
			elseif Key == "c" then
628
				if Current.Part and Current.Part.Parent ~= nil and not Multi then
629
					local Part = getTargFromCurrent()
630
					if Part then
631
						Grabbing = false
632
						if Mouse.Hit then
633
							local TargPos = CFrame.new(Camera.CoordinateFrame.p, Mouse.Hit.p) * CFrame.new(0, 0, -1000)
634
							Fire(Part, TargPos.p)
635
						else
636
							Fire(Part, Mouse.Origin.p + Mouse.UnitRay.Direction, true)
637
						end
638
					end
639
				end
640
			end
641
		end))
642
643
		table.insert(Cons, Mouse.Button1Up:connect(function()
644
			mDown = false
645
			if Grabbing == true and Multi == false then
646
				Grabbing = false
647
				Reset()
648
			end
649
			if Current.Part ~= nil then
650
				LastPart = getTargFromCurrent()
651
				Current = {}
652
			end
653
		end))
654
655
		local function makeLightning(Par, Start, End, Width, Length, RandomScale, ArcScale, Num1)
656
			local oldParts = {}
657
			for _,v in pairs(Par:GetChildren()) do
658
				v.CFrame = CFrame.new(5e5, 5e5, 5e5)
659
				table.insert(oldParts, v)
660
			end
661
			local Distance = (Start-End).Magnitude
662
			local ArcScale = ArcScale or 1
663
			local RandomScale = RandomScale or 0
664
			local Last = Start
665
			local IterNum = 0
666
667
			while Par.Parent do
668
				IterNum = IterNum + 1
669
				local New = nil
670
				if (Last-End).Magnitude < Length then
671
					New = CFrame.new(End)
672
				else
673
					if (End-Last).Magnitude < Length*2 then
674
						RandomScale = RandomScale*0.5
675
						ArcScale = ArcScale*0.5
676
					end
677
					local Direct = CFrame.new(Last,End)
678
					New = Direct*CFrame.Angles(math.rad(math.random(-RandomScale/4,RandomScale*ArcScale)),math.rad(math.random(-RandomScale,RandomScale)),math.rad(math.random(-RandomScale,RandomScale)))
679
					New = New*CFrame.new(0,0,-Length)
680
				end
681
				local Trail = nil
682
				if oldParts[IterNum] then
683
					Trail = oldParts[IterNum]
684
					Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("Lime green")) or BrickColor.new("Earth green")
685
					Trail.Size = Vector3.new(Width, (Last-New.p).Magnitude, Width)
686
					Trail.CFrame = CFrame.new(New.p, Last)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0, -(Last-New.p).Magnitude/2, 0)
687
					oldParts[IterNum] = nil
688
				else
689
					Trail = Instance.new("Part")
690-
					Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("White")) or BrickColor.new("Cyan")
690+
691
					Trail.FormFactor = "Custom"
692
					Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("Lime green")) or BrickColor.new("Lime green")
693
					Trail.Transparency = 0
694
					Trail.Anchored = true
695
					Trail.CanCollide = false
696
					Trail.Locked = true
697
					Trail.BackSurface = "SmoothNoOutlines"
698-
					Trail.BrickColor = ((Num1 % 2 == 0) and BrickColor.new("White")) or BrickColor.new("White")
698+
699
					Trail.FrontSurface = "SmoothNoOutlines"
700
					Trail.LeftSurface = "SmoothNoOutlines"
701
					Trail.RightSurface = "SmoothNoOutlines"
702
					Trail.TopSurface = "SmoothNoOutlines"
703
					Trail.Material = "Grass"
704
					Trail.Size = Vector3.new(Width, (Last-New.p).Magnitude, Width)
705
					Trail.CFrame = CFrame.new(New.p, Last)*CFrame.Angles(math.rad(90),0,0)*CFrame.new(0, -(Last-New.p).Magnitude/2, 0)
706
					Trail.Parent = Par
707
				end
708
				Last = New.p
709-
					Trail.Material = "Neon"
709+
710
					break
711
				end
712
			end
713
			for _,v in pairs(oldParts) do
714
				v:Destroy()
715
			end
716
		end
717
718
		table.insert(Cons, Mouse.Button1Down:connect(function()
719
			mDown = true
720
			local Targ = Mouse.Target
721
			Cor(function()
722
				if Targ and Objects[Targ] and not Multi then
723
					Grabbing = true
724
					Current.Part = Targ
725
					local Mass = Objects[Targ]
726
					local ForceNum = 0
727
					local Hum = nil
728
					
729
					for _,v in pairs(Targ:GetChildren()) do
730
						if BodyObjects[v.ClassName] then
731
							v:Destroy()
732
						end
733
					end
734
					
735
					for _,v in pairs(Workspace:GetChildren()) do
736
						if v:findFirstChild("Humanoid") and v:IsAncestorOf(Targ) then
737
							Hum = v.Humanoid
738
							Mass = getMass(v, 0)
739
							Current.Part = v
740
							break
741
						end
742
					end
743
					
744
					Current.Mass = Mass
745
					
746
					if not Hum then
747
						Targ:BreakJoints()
748
					end
749
					
750
					ForceNum = Mass * Grav
751
					Targ.CanCollide = true
752
					Targ.Anchored = false
753
					
754
					local BP = Instance.new("BodyPosition")
755
					BP.maxForce = Vector3.new(3 * ForceNum, 3 * ForceNum, 3 * ForceNum)
756
					BP.Parent = Targ
757
					
758
					local Ang = Instance.new("BodyAngularVelocity")
759
					Ang.Parent = Targ
760
					
761
					Current.BP = BP
762
					Current.BA = Ang
763
					
764
					OrigLS.Parent = nil
765
					OrigRS.Parent = nil
766
					
767
					LS.Parent = Torso
768
					RS.Parent = Torso
769
					
770
					LS.C0 = LS0
771
					RS.C0 = RS0
772
					
773
					local DirDot = Mouse.UnitRay.Direction:Dot(Targ.Position - Mouse.Origin.p)
774
					local BPPos = Vector3.new(0, 0, 0)
775
					local Vel = Vector3.new(0, 0, 0)
776
					local Vlev = random() * math.pi
777
					local RPos = Vector3.new(random() * 2 - 1, cos(Vlev), random() * 2 - 1)
778
					
779
					local Ball = Instance.new("Part")
780
					Ball.Name = "Ball"
781
					Ball.FormFactor = "Custom"
782
					Ball.Color = Color3.new(0, 1, 1)
783
					Ball.Transparency = 0.3
784
					Ball.Anchored = true
785
					Ball.CanCollide = false
786
					Ball.Locked = true
787
					Ball.BottomSurface, Ball.TopSurface = "Smooth", "Smooth"
788
					Ball.Size = Vector3.new(0.5, 0.5, 0.5)
789
					Ball.CFrame = Torso.CFrame * CFrame.new(0, 1, -3)
790
					Ball.Parent = Char
791
792
					if Targ.Name == "MyPartV" then
793
						Targ.Name = "MyPartF"
794
					end
795
796
					local LightMod = Instance.new("Model", Char)
797
						
798
					local Mesh = Instance.new("SpecialMesh")
799
					Mesh.MeshType = "Sphere"
800
					Mesh.Parent = Ball
801
					
802
					local Size = 0.5
803
					local Rise = true
804
					
805
					while Grabbing and BP and Ang and Targ.Parent ~= nil do
806
						local BPPos = Mouse.Origin.p + Mouse.UnitRay.Direction * DirDot
807
						Ang.angularvelocity = Vel
808
						BP.position = BPPos + RPos
809
						RPos = Vector3.new(max(-1, min(RPos.x + random() * 0.02 - 0.01, 1)), cos(Vlev), max(-1, min(RPos.z + random() * 0.02 - 0.01, 1)))
810
						Vel = Vector3.new(max(-1, min(Vel.x + random() * 0.2 - 0.1, 1)), max(-1, min(Vel.y + random() * 0.2 - 0.1, 1)), max(-1, min(Vel.z + random() * 0.2 - 0.1, 1)))
811
						Vlev = (Vlev + 0.05) % tau
812
						
813
						if Hum then
814
							Hum.Sit = true
815
						end
816
						
817
						if LA.Parent ~= nil and RA.Parent ~= nil then
818
							local LPos = (LA.CFrame * CFrame.new(0, -1, 0)).p
819
							local RPos = (RA.CFrame * CFrame.new(0, -1, 0)).p
820
							if Rise == true then
821
								if Size < 0.6 then
822
									Size = Size + 0.05
823
								else
824
									Size = Size + 0.1
825
								end
826
								if Size >= 2.2 then
827
									Rise = false
828
								end
829
							else
830
								if Size > 2.1 then
831
									Size = Size - 0.05
832
								else
833
									Size = Size - 0.1
834
								end
835
								if Size <= 0.5 then
836
									Rise = true
837
								end
838
							end
839
							Ball.Size = Vector3.new(Size, Size, Size)
840
							Ball.CFrame = CFrame.new(LPos:Lerp(RPos, 0.5), Targ.Position) * CFrame.new(0, 0, -2.2)
841
							LightNum = LightNum + 1
842
							makeLightning(LightMod, Ball.Position, Targ.Position, 0.2, 4, 50, 1, LightNum)
843
						elseif Ball.Parent ~= nil then
844
							Ball:Destroy()
845
						end
846
						
847
						if LS and LS.Parent == Torso then
848
							LS.C0 = CFrame.new(Vector3.new(-1.5, 0.5, 0), Torso.CFrame:pointToObjectSpace((Targ.CFrame or Torso.CFrame * CFrame.new(-1.5, 0.5, 1)).p))
849
						end
850
						if RS and RS.Parent == Torso then
851
							RS.C0 = CFrame.new(Vector3.new(1.5, 0.5, 0), Torso.CFrame:pointToObjectSpace((Targ.CFrame or Torso.CFrame * CFrame.new(1.5, 0.5, 1)).p))
852
						end
853
						RunService.Heartbeat:wait()
854
					end
855
856
					coroutine.resume(coroutine.create(function()
857
						for i = 0.5, 1, 0.1 do
858
							for i2,v in pairs(LightMod:GetChildren()) do
859
								--v.Light.Range = 6-(i*5)
860
								v.Transparency = i
861
							end
862
							wait(1/30)
863
						end
864
						LightMod:Destroy()
865
					end))
866
					
867
					if BP and BP.Parent ~= nil then
868
						BP:Destroy()
869
					end
870
					
871
					if Ang and Ang.Parent ~= nil then
872
						Ang:Destroy()
873
					end
874
					
875
					pcall(function() Ball:Destroy() end)
876
				end
877
			end)
878
		end))
879
	end)
880
end
881
882
function Add(Obj)
883
	if Obj:IsA("BasePart") and not Objects[Obj] and not (Obj.Name == "Base" and Obj.ClassName == "Part") then
884
		Objects[Obj] = Obj:GetMass()
885
		Obj.Changed:connect(function(P)
886
			if P:lower() == "size" and Objects[Obj] and Obj.Parent ~= nil then
887
				Objects[Obj] = Obj:GetMass()
888
			end
889
		end)
890
	end
891
end
892
893
function Rem(Obj)
894
	if Objects[Obj] then
895
		Objects[Obj] = nil
896
	end
897
end
898
899
function Recursion(Obj)
900
	ypcall(function()
901
		Add(Obj)
902
		if #Obj:GetChildren() > 0 then
903
			for _,v in pairs(Obj:GetChildren()) do 
904
				Recursion(v)
905
			end
906
		end
907
	end)
908
end
909
910
Workspace.DescendantAdded:connect(function(Obj)
911
	Add(Obj)
912
end)
913
914
Workspace.DescendantRemoving:connect(function(Obj)
915
	Rem(Obj)
916
end)
917
918
for _,v in pairs(Workspace:GetChildren()) do
919
	Recursion(v)
920
end
921
922
Start()
923
924
if LP.Name == PlrName then
925
	LP.CharacterAdded:connect(Start)
926
end
927
928
local verlet = {}
929
verlet.step_time = 1 / 50
930
verlet.gravity = Vector3.new(0, -10, 0)
931
932
local char = game.Players.LocalPlayer.Character
933
local torso = char:WaitForChild("Torso")
934
local parts = {}
935
local render = game:GetService("RunService").RenderStepped
936
937
wait(2)
938
939
local point = {}
940
local link = {}
941
local rope = {}
942
943
local function ccw(A,B,C)
944
    return (C.y-A.y) * (B.x-A.x) > (B.y-A.y) * (C.x-A.x)
945
end
946
947
local function intersect(A,B,C,D)
948
    return ccw(A,C,D) ~= ccw(B,C,D) and ccw(A,B,C) ~= ccw(A,B,D)
949
end
950
951
local function vec2(v)
952
	return Vector2.new(v.x, v.z)
953
end
954
955
function point:step()
956
	if not self.fixed then
957
		local derivative = (self.position - self.last_position) * 0.95
958
		self.last_position = self.position
959
		self.position = self.position + derivative + (self.velocity * verlet.step_time ^ 2)
960
		--[[local torsoP = torso.CFrame * CFrame.new(-1, 0, 0.5)
961
		local torsoE = torso.CFrame * CFrame.new(1, 0, 0.5)
962
		local pointE = self.position + torso.CFrame.lookVector * 100
963
		local doIntersect = intersect(vec2(torsoP.p), vec2(torsoE.p), vec2(self.position), vec2(pointE))
964
		if not doIntersect then
965
			self.postition = self.position - torso.CFrame.lookVector * 10
966
		end]]
967
	end
968
end
969
970
function link:step()
971
	for i = 1, 1 do
972
		local distance = self.point1.position - self.point2.position
973
		local magnitude = distance.magnitude
974
		local differance = (self.length - magnitude) / magnitude
975
		local translation = ((self.point1.fixed or self.point2.fixed) and 1 or 0.6) * distance * differance
976
		if not self.point1.fixed then
977
			self.point1.position = self.point1.position + translation
978
		end
979
		if not self.point2.fixed then
980
			self.point2.position = self.point2.position - translation
981
		end
982
	end
983
end
984
985
function verlet.new(class, a, b, c)
986
	if class == "Point" then
987
		local new = {}
988
		setmetatable(new, {__index = point})
989
		new.class = class
990
		new.position = a or Vector3.new()
991
		new.last_position = new.position
992
		new.velocity = verlet.gravity
993
		new.fixed = false
994
		return new
995
	elseif class == "Link" then
996
		local new = {}
997
		setmetatable(new, {__index = link})
998
		new.class = class
999
		new.point1 = a
1000
		new.point2 = b
1001
		new.length = c or (a.position - b.position).magnitude
1002
		return new
1003
	elseif class == "Rope" then
1004
		local new = {}
1005
		setmetatable(new, {__index = link})
1006
		new.class = class
1007
		new.start_point = a
1008
		new.finish_point = b
1009
		new.points = {}
1010
		new.links = {}
1011
		local inc = (b - a) / 10
1012
		for i = 0, 10 do
1013
			table.insert(new.points, verlet.new("Point", a + (i * inc)))
1014
		end
1015
		for i = 2, #new.points do
1016
			table.insert(new.links, verlet.new("Link", new.points[i - 1], new.points[i]))
1017
		end
1018
		return new
1019
	end
1020
end
1021
1022
local tris = {}
1023
local triParts = {}
1024
1025
local function GetDiscoColor(hue)
1026
 local section = hue % 1 * 3
1027
 local secondary = 0.5 * math.pi * (section % 1)
1028
 if section < 1 then
1029
  return Color3.new(0, 0, 0)
1030
 elseif section < 2 then
1031
  return Color3.new(0, 0, 0)
1032
 else
1033
  return Color3.new(0, 0, 0)
1034
 end
1035
end
1036
1037
local function setupPart(part)
1038
	part.Anchored = true
1039
	part.FormFactor = 3
1040
	part.CanCollide = false
1041
	part.TopSurface = 10
1042
	part.BottomSurface = 10
1043
	part.LeftSurface = 10
1044
	part.RightSurface = 10
1045
	part.FrontSurface = 10
1046
	part.BackSurface = 10
1047
	part.Material = "Neon"
1048
	local m = Instance.new("SpecialMesh", part)
1049
	m.MeshType = "Wedge"
1050
	m.Scale = Vector3.new(0.2, 1, 1)
1051
	return part
1052
end
1053
1054
local function CFrameFromTopBack(at, top, back)
1055
	local right = top:Cross(back)
1056
	return CFrame.new(at.x, at.y, at.z, right.x, top.x, back.x,  right.y, top.y, back.y, right.z, top.z, back.z)
1057
end
1058
1059
local function drawTri(parent, a, b, c)
1060
	local this = {}
1061
	local mPart1 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
1062
	local mPart2 = table.remove(triParts, 1) or setupPart(Instance.new("Part"))
1063
	function this:Set(a, b, c)
1064
		local ab, bc, ca = b-a, c-b, a-c
1065
		local abm, bcm, cam = ab.magnitude, bc.magnitude, ca.magnitude
1066
		local edg1 = math.abs(0.5 + ca:Dot(ab)/(abm*abm))
1067
		local edg2 = math.abs(0.5 + ab:Dot(bc)/(bcm*bcm))
1068
		local edg3 = math.abs(0.5 + bc:Dot(ca)/(cam*cam))
1069
		if edg1 < edg2 then
1070
			if edg1 >= edg3 then		
1071
				a, b, c = c, a, b
1072
				ab, bc, ca = ca, ab, bc
1073
				abm = cam
1074
			end
1075
		else
1076
			if edg2 < edg3 then
1077
				a, b, c = b, c, a
1078
				ab, bc, ca = bc, ca, ab
1079
				abm = bcm
1080
			else
1081
				a, b, c = c, a, b
1082
				ab, bc, ca = ca, ab, bc
1083
				abm = cam
1084
			end
1085
		end
1086
	 
1087
		local len1 = -ca:Dot(ab)/abm
1088
		local len2 = abm - len1
1089
		local width = (ca + ab.unit*len1).magnitude
1090
	 
1091
		local maincf = CFrameFromTopBack(a, ab:Cross(bc).unit, -ab.unit)
1092
	 
1093
		if len1 > 0.2 then
1094
			mPart1.Parent = parent
1095
			mPart1.Size = Vector3.new(0.2, width, len1)
1096
			mPart1.CFrame = maincf*CFrame.Angles(math.pi,0,math.pi/2)*CFrame.new(0,width/2,len1/2)
1097
		else
1098
			mPart1.Parent = nil
1099
		end
1100
		
1101
		if len2 > 0.2 then
1102
			mPart2.Parent = parent
1103
			mPart2.Size = Vector3.new(0.2, width, len2)
1104
			mPart2.CFrame = maincf*CFrame.Angles(math.pi,math.pi,-math.pi/2)*CFrame.new(0,width/2,-len1 - len2/2)
1105
		else
1106
			mPart2.Parent = nil
1107
		end	
1108
	end
1109
	function this:SetProperty(prop, value)
1110
		mPart1[prop] = value
1111
		mPart2[prop] = value
1112
	end
1113
	this:Set(a, b, c)
1114
	function this:Destroy()
1115
		mPart1:Destroy()
1116
		mPart2:Destroy()
1117
	end
1118
	this.p1 = mPart1
1119
	this.p2 = mPart2
1120
	this.p1.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p1.CFrame.Y * 0.5 + time())))
1121
	this.p2.BrickColor = BrickColor.new(GetDiscoColor(math.noise(0.5, 0.5, this.p2.CFrame.Y * 0.5 + time())))
1122
	return this
1123
end
1124
1125
function verlet.draw(object, id)
1126
	if object.class == "Point" then
1127
		local part = parts[id]
1128
		part.BrickColor = BrickColor.new(107, 0, 107)
1129
		part.Transparency = 0
1130
		part.formFactor = 3
1131
		part.Anchored = true
1132
		part.CanCollide = false
1133
		part.TopSurface = 0
1134
		part.BottomSurface = 0
1135
		part.Size = Vector3.new(0.35, 0.35, 0.35)
1136
		part.Material = "Neon"
1137
		part.CFrame = CFrame.new(object.position)
1138
		part.Parent = torso
1139
		return part
1140
	elseif object.class == "Link" then
1141
		local part = parts[id]
1142
		local dist = (object.point1.position - object.point2.position).magnitude
1143
		part.Size = Vector3.new(0.2, 0.2, dist)
1144
		part.CFrame = CFrame.new(object.point1.position, object.point2.position) * CFrame.new(0, 0, dist * -0.5)
1145
		part.Parent = torso
1146
		return part
1147
	end
1148
end
1149
1150
function verlet.clear()
1151
	for _, v in pairs(workspace:GetChildren()) do
1152
		if v.Name == "Part" then
1153
			v:Destroy()
1154
		end
1155
	end
1156
end
1157
1158
local points = {}
1159
local links = {}
1160
1161
for x = 0, 2 do
1162
	points[x] = {}
1163
	for y = 0, 3 do
1164
		points[x][y] = verlet.new("Point", torso.Position + Vector3.new(x * 0.8 - 2, 2 - y * 0.8, 5 + y * 0.4))
1165
		points[x][y].fixed = y == 0
1166
	end
1167
end
1168
1169
for x = 1, 2 do
1170
	for y = 0, 3 do
1171
		links[#links + 1] = verlet.new("Link", points[x][y], points[x - 1][y], 1 + y * 0.08)
1172
	end
1173
end
1174
1175
for x = 0, 2 do
1176
	for y = 1, 3 do
1177
		links[#links + 1] = verlet.new("Link", points[x][y], points[x][y - 1], 1.2 + y * 0.03)
1178
	end
1179
end
1180
1181
render:connect(function()
1182
	for x = 0, 2 do
1183
		for y = 0, 3 do
1184
			if y == 0 then
1185
				points[x][y].position = (torso.CFrame * CFrame.new(x * 1 - 1, 1, 0.5)).p
1186
			else
1187
				points[x][y]:step()
1188
			end
1189
		end
1190
	end
1191
	for i = 1, #links do
1192
		links[i]:step()
1193
	end
1194
	for i = 1, #tris do
1195
		triParts[#triParts + 1] = tris[i].p1
1196
		triParts[#triParts + 1] = tris[i].p2
1197
	end
1198
	tris = {}
1199
	for x = 1, 2 do
1200
		for y = 1, 3 do
1201
			tris[#tris + 1] = drawTri(torso, points[x - 1][y - 1].position, points[x - 1][y].position, points[x][y - 1].position)
1202
			tris[#tris + 1] = drawTri(torso, points[x][y].position, points[x - 1][y].position, points[x][y - 1].position)
1203
		end
1204
	end
1205
end)