-
Notifications
You must be signed in to change notification settings - Fork 0
/
SudoLUA
1068 lines (969 loc) · 34.3 KB
/
SudoLUA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function sandbox(var,func)
local env = getfenv(func)
local newenv = setmetatable({},{
__index = function(self,k)
if k=="script" then
return var
else
return env[k]
end
end,
})
setfenv(func,newenv)
return func
end
cors = {}
mas = Instance.new("Model",game:GetService("Lighting"))
Tool0 = Instance.new("Tool")
Part1 = Instance.new("Part")
CylinderMesh2 = Instance.new("CylinderMesh")
Part3 = Instance.new("Part")
LocalScript4 = Instance.new("LocalScript")
Script5 = Instance.new("Script")
LocalScript6 = Instance.new("LocalScript")
Script7 = Instance.new("Script")
LocalScript8 = Instance.new("LocalScript")
Part9 = Instance.new("Part")
Script10 = Instance.new("Script")
Part11 = Instance.new("Part")
Script12 = Instance.new("Script")
Part13 = Instance.new("Part")
Script14 = Instance.new("Script")
Tool0.Name = "Telekinesis Gun"
Tool0.Parent = mas
Tool0.CanBeDropped = false
Part1.Name = "Handle"
Part1.Parent = Tool0
Part1.Material = Enum.Material.Neon
Part1.BrickColor = BrickColor.new("Cyan")
Part1.Transparency = 1
Part1.Rotation = Vector3.new(0, 15.4200001, 0)
Part1.CanCollide = false
Part1.FormFactor = Enum.FormFactor.Custom
Part1.Size = Vector3.new(1, 0.400000036, 0.300000012)
Part1.CFrame = CFrame.new(-55.2695465, 0.696546972, 0.383156985, 0.96399641, -4.98074878e-05, 0.265921414, 4.79998416e-05, 1, 1.32960558e-05, -0.265921414, -5.30653779e-08, 0.96399641)
Part1.BottomSurface = Enum.SurfaceType.Smooth
Part1.TopSurface = Enum.SurfaceType.Smooth
Part1.Color = Color3.new(0.0156863, 0.686275, 0.92549)
Part1.Position = Vector3.new(-55.2695465, 0.696546972, 0.383156985)
Part1.Orientation = Vector3.new(0, 15.4200001, 0)
Part1.Color = Color3.new(0.0156863, 0.686275, 0.92549)
CylinderMesh2.Parent = Part1
CylinderMesh2.Scale = Vector3.new(0.100000001, 0.100000001, 0.100000001)
CylinderMesh2.Scale = Vector3.new(0.100000001, 0.100000001, 0.100000001)
Part3.Name = "Shoot"
Part3.Parent = Tool0
Part3.Material = Enum.Material.Neon
Part3.BrickColor = BrickColor.new("Cyan")
Part3.Reflectance = 0.30000001192093
Part3.Transparency = 1
Part3.Rotation = Vector3.new(90.9799957, 0.25999999, -91.409996)
Part3.CanCollide = false
Part3.FormFactor = Enum.FormFactor.Custom
Part3.Size = Vector3.new(0.200000003, 0.25, 0.310000032)
Part3.CFrame = CFrame.new(-54.7998123, 0.774299085, -0.757350147, -0.0245519895, 0.99968797, 0.00460194098, 0.0169109926, 0.00501798885, -0.999844491, -0.999555528, -0.0244703442, -0.0170289185)
Part3.BottomSurface = Enum.SurfaceType.Smooth
Part3.TopSurface = Enum.SurfaceType.Smooth
Part3.Color = Color3.new(0.0156863, 0.686275, 0.92549)
Part3.Position = Vector3.new(-54.7998123, 0.774299085, -0.757350147)
Part3.Orientation = Vector3.new(88.9899979, 164.87999, 73.4700012)
Part3.Color = Color3.new(0.0156863, 0.686275, 0.92549)
LocalScript4.Parent = Tool0
table.insert(cors,sandbox(LocalScript4,function()
-- Variables for services
local render = game:GetService("RunService").RenderStepped
local contextActionService = game:GetService("ContextActionService")
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Tool = script.Parent
-- Variables for Module Scripts
local screenSpace = require(Tool:WaitForChild("ScreenSpace"))
local connection
-- Variables for character joints
local neck, shoulder, oldNeckC0, oldShoulderC0
local mobileShouldTrack = true
-- Thourough check to see if a character is sitting
local function amISitting(character)
local t = character.Torso
for _, part in pairs(t:GetConnectedParts(true)) do
if part:IsA("Seat") or part:IsA("VehicleSeat") then
return true
end
end
end
-- Function to call on renderstepped. Orients the character so it is facing towards
-- the player mouse's position in world space. If character is sitting then the torso
-- should not track
local function frame(mousePosition)
-- Special mobile consideration. We don't want to track if the user was touching a ui
-- element such as the movement controls. Just return out of function if so to make sure
-- character doesn't track
if not mobileShouldTrack then return end
-- Make sure character isn't swiming. If the character is swimming the following code will
-- not work well; the character will not swim correctly. Besides, who shoots underwater?
if player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
local torso = player.Character.Torso
local head = player.Character.Head
local toMouse = (mousePosition - head.Position).unit
local angle = math.acos(toMouse:Dot(Vector3.new(0,1,0)))
local neckAngle = angle
-- Limit how much the head can tilt down. Too far and the head looks unnatural
if math.deg(neckAngle) > 110 then
neckAngle = math.rad(110)
end
neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(math.pi - neckAngle,math.pi,0)
-- Calculate horizontal rotation
local arm = player.Character:FindFirstChild("Right Arm")
local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(
torso.Size.X/2 + arm.Size.X/2, torso.Size.Y/2 - arm.Size.Z/2, 0))
local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1,0,1)).unit
local look = (torso.CFrame.lookVector * Vector3.new(1,0,1)).unit
local lateralAngle = math.acos(toMouseArm:Dot(look))
-- Check for rogue math
if tostring(lateralAngle) == "-1.#IND" then
lateralAngle = 0
end
-- Handle case where character is sitting down
if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
local cross = torso.CFrame.lookVector:Cross(toMouseArm)
if lateralAngle > math.pi/2 then
lateralAngle = math.pi/2
end
if cross.Y < 0 then
lateralAngle = -lateralAngle
end
end
-- Turn shoulder to point to mouse
shoulder.C0 = CFrame.new(1,0.5,0) * CFrame.Angles(math.pi/2 - angle,math.pi/2 + lateralAngle,0)
-- If not sitting then aim torso laterally towards mouse
if not amISitting(player.Character) then
torso.CFrame = CFrame.new(torso.Position, torso.Position + (Vector3.new(
mousePosition.X, torso.Position.Y, mousePosition.Z)-torso.Position).unit)
else
--print("sitting")
end
end
end
-- Function to bind to render stepped if player is on PC
local function pcFrame()
frame(mouse.Hit.p)
end
-- Function to bind to touch moved if player is on mobile
local function mobileFrame(touch, processed)
-- Check to see if the touch was on a UI element. If so, we don't want to update anything
if not processed then
-- Calculate touch position in world space. Uses Stravant's ScreenSpace Module script
-- to create a ray from the camera.
local test = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1)
local nearPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1))
nearPos = game.Workspace.CurrentCamera.CoordinateFrame.p - nearPos
local farPos = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y,50)
farPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(farPos) * -1
if farPos.magnitude > 900 then
farPos = farPos.unit * 900
end
local ray = Ray.new(nearPos, farPos)
local part, pos = game.Workspace:FindPartOnRay(ray, player.Character)
-- if a position was found on the ray then update the character's rotation
if pos then
frame(pos)
end
end
end
local oldIcon = nil
-- Function to bind to equip event
local function equip()
local torso = player.Character.Torso
-- Setup joint variables
neck = torso.Neck
oldNeckC0 = neck.C0
shoulder = torso:FindFirstChild("Right Shoulder")
oldShoulderC0 = shoulder.C0
-- Remember old mouse icon and update current
oldIcon = mouse.Icon
mouse.Icon = "rbxassetid:// 2184939409"
-- Bind TouchMoved event if on mobile. Otherwise connect to renderstepped
if userInputService.TouchEnabled then
connection = userInputService.TouchMoved:connect(mobileFrame)
else
connection = render:connect(pcFrame)
end
-- Bind TouchStarted and TouchEnded. Used to determine if character should rotate
-- during touch input
userInputService.TouchStarted:connect(function(touch, processed)
mobileShouldTrack = not processed
end)
userInputService.TouchEnded:connect(function(touch, processed)
mobileShouldTrack = false
end)
-- Fire server's equip event
game.ReplicatedStorage.ROBLOX_PistolEquipEvent:FireServer()
-- Bind event for when mouse is clicked to fire server's fire event
mouse.Button1Down:connect(function()
game.ReplicatedStorage.ROBLOX_PistolFireEvent:FireServer(mouse.Hit.p)
end)
-- Bind reload event to mobile button and r key
contextActionService:BindActionToInputTypes("Reload", function()
game.ReplicatedStorage.ROBLOX_PistolReloadEvent:FireServer()
end, true, "")
-- If game uses filtering enabled then need to update server while tool is
-- held by character.
if workspace.FilteringEnabled then
while connection do
wait()
game.ReplicatedStorage.ROBLOX_PistolUpdateEvent:FireServer(neck.C0, shoulder.C0)
end
end
end
-- Function to bind to Unequip event
local function unequip()
if connection then connection:disconnect() end
contextActionService:UnbindAction("Reload")
game.ReplicatedStorage.ROBLOX_PistolUnequipEvent:FireServer()
mouse.Icon = oldIcon
neck.C0 = oldNeckC0
shoulder.C0 = oldShoulderC0
end
-- Bind tool events
Tool.Equipped:connect(equip)
Tool.Unequipped:connect(unequip)
end))
Script5.Name = "qPerfectionWeld"
Script5.Parent = Tool0
table.insert(cors,sandbox(Script5,function()
-- Created by Quenty (@Quenty, follow me on twitter).
-- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
-- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
--[[ INSTRUCTIONS
- Place in the model
- Make sure model is anchored
- That's it. It will weld the model and all children.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
This script is designed to be used is a regular script. In a local script it will weld, but it will not attempt to handle ancestory changes.
]]
--[[ DOCUMENTATION
- Will work in tools. If ran more than once it will not create more than one weld. This is especially useful for tools that are dropped and then picked up again.
- Will work in PBS servers
- Will work as long as it starts out with the part anchored
- Stores the relative CFrame as a CFrame value
- Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
- Utilizes a recursive algorith to find all parts in the model
- Will reweld on script reparent if the script is initially parented to a tool.
- Welds as fast as possible
]]
-- qPerfectionWeld.lua
-- Created 10/6/2014
-- Author: Quenty
-- Version 1.0.3
-- Updated 10/14/2014 - Updated to 1.0.1
--- Bug fix with existing ROBLOX welds ? Repro by asimo3089
-- Updated 10/14/2014 - Updated to 1.0.2
--- Fixed bug fix.
-- Updated 10/14/2014 - Updated to 1.0.3
--- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
local function CallOnChildren(Instance, FunctionToCall)
-- Calls a function on each of the children of a certain object, using recursion.
FunctionToCall(Instance)
for _, Child in next, Instance:GetChildren() do
CallOnChildren(Child, FunctionToCall)
end
end
local function GetNearestParent(Instance, ClassName)
-- Returns the nearest parent of a certain class, or returns nil
local Ancestor = Instance
repeat
Ancestor = Ancestor.Parent
if Ancestor == nil then
return nil
end
until Ancestor:IsA(ClassName)
return Ancestor
end
local function GetBricks(StartInstance)
local List = {}
-- if StartInstance:IsA("BasePart") then
-- List[#List+1] = StartInstance
-- end
CallOnChildren(StartInstance, function(Item)
if Item:IsA("BasePart") then
List[#List+1] = Item;
end
end)
return List
end
local function Modify(Instance, Values)
-- Modifies an Instance by using a table.
assert(type(Values) == "table", "Values is not a table");
for Index, Value in next, Values do
if type(Index) == "number" then
Value.Parent = Instance
else
Instance[Index] = Value
end
end
return Instance
end
local function Make(ClassType, Properties)
-- Using a syntax hack to create a nice way to Make new items.
return Modify(Instance.new(ClassType), Properties)
end
local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
local function HasWheelJoint(Part)
for _, SurfaceName in pairs(Surfaces) do
for _, HingSurfaceName in pairs(HingSurfaces) do
if Part[SurfaceName].Name == HingSurfaceName then
return true
end
end
end
return false
end
local function ShouldBreakJoints(Part)
--- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
-- definitely some edge cases.
if NEVER_BREAK_JOINTS then
return false
end
if HasWheelJoint(Part) then
return false
end
local Connected = Part:GetConnectedParts()
if #Connected == 1 then
return false
end
for _, Item in pairs(Connected) do
if HasWheelJoint(Item) then
return false
elseif not Item:IsDescendantOf(script.Parent) then
return false
end
end
return true
end
local function WeldTogether(Part0, Part1, JointType, WeldParent)
--- Weld's 2 parts together
-- @param Part0 The first part
-- @param Part1 The second part (Dependent part most of the time).
-- @param [JointType] The type of joint. Defaults to weld.
-- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
-- @return The weld created.
JointType = JointType or "Weld"
local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
Modify(NewWeld, {
Name = "qCFrameWeldThingy";
Part0 = Part0;
Part1 = Part1;
C0 = CFrame.new();--Part0.CFrame:inverse();
C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
Parent = Part1;
})
if not RelativeValue then
RelativeValue = Make("CFrameValue", {
Parent = Part1;
Name = "qRelativeCFrameWeldValue";
Archivable = true;
Value = NewWeld.C1;
})
end
return NewWeld
end
local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
-- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
-- @param MainPart The part to weld the model to (can be in the model).
-- @param [JointType] The type of joint. Defaults to weld.
-- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
for _, Part in pairs(Parts) do
if ShouldBreakJoints(Part) then
Part:BreakJoints()
end
end
for _, Part in pairs(Parts) do
if Part ~= MainPart then
WeldTogether(MainPart, Part, JointType, MainPart)
end
end
if not DoNotUnanchor then
for _, Part in pairs(Parts) do
Part.Anchored = false
end
MainPart.Anchored = false
end
end
local function PerfectionWeld()
local Tool = GetNearestParent(script, "Tool")
local Parts = GetBricks(script.Parent)
local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
if PrimaryPart then
WeldParts(Parts, PrimaryPart, "Weld", false)
else
warn("qWeld - Unable to weld part")
end
return Tool
end
local Tool = PerfectionWeld()
if Tool and script.ClassName == "Script" then
--- Don't bother with local scripts
script.Parent.AncestryChanged:connect(function()
PerfectionWeld()
end)
end
-- Created by Quenty (@Quenty, follow me on twitter).
end))
LocalScript6.Name = "Animate"
LocalScript6.Parent = Tool0
table.insert(cors,sandbox(LocalScript6,function()
local arms = nil
local torso = nil
local welds = {}
local Tool = script.Parent
local neck = nil
local orginalC0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
function Equip(mouse)
wait(0.01)
arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
head = Tool.Parent:FindFirstChild("Head")
torso = Tool.Parent:FindFirstChild("Torso")
if neck == nil then
neck = Tool.Parent:FindFirstChild("Torso").Neck
end
if arms ~= nil and torso ~= nil then
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
if sh ~= nil then
local yes = true
if yes then
yes = false
sh[1].Part1 = nil
sh[2].Part1 = nil
local weld1 = Instance.new("Weld")
weld1.Part0 = head
weld1.Parent = head
weld1.Part1 = arms[1]
welds[1] = weld1
local weld2 = Instance.new("Weld")
weld2.Part0 = head
weld2.Parent = head
weld2.Part1 = arms[2]
welds[2] = weld2
-------------------------here
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
mouse.Move:connect(function ()
--local Direction = Tool.Direction.Value
local Direction = mouse.Hit.p
local b = head.Position.Y-Direction.Y
local dist = (head.Position-Direction).magnitude
local answer = math.asin(b/dist)
neck.C0=orginalC0*CFrame.fromEulerAnglesXYZ(answer,0,0)
wait(0.1)
end)end
else
print("sh")
end
else
print("arms")
end
end
function Unequip(mouse)
if arms ~= nil and torso ~= nil then
local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
if sh ~= nil then
local yes = true
if yes then
yes = false
neck.C0 = orginalC0
sh[1].Part1 = arms[1]
sh[2].Part1 = arms[2]
welds[1].Parent = nil
welds[2].Parent = nil
end
else
print("sh")
end
else
print("arms")
end
end
Tool.Equipped:connect(Equip)
Tool.Unequipped:connect(Unequip)
function Animate()
arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
if Tool.AnimateValue.Value == "Shoot" then
local weld1 = welds[1]
local weld2 = welds[2]
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
wait(0.00001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.05, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
wait(0.00001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.1, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-95), math.rad(-15), 0)
wait(0.00001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.3, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-110), math.rad(-15), 0)
wait(0.00001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.35, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-115), math.rad(-15), 0)
wait(0.00001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.00001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
Tool.AnimateValue.Value = "None"
end
if Tool.AnimateValue.Value == "Reload" then
local weld1 = welds[1]
local weld2 = welds[2]
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-95), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-100), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-105), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-110), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.4, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-115), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.45, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.9, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.5, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 1, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.55, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 1.1, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.57, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 1.2, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.6, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 1.3, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0.6, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-120), math.rad(-15), 0)
wait(0.0001)
weld1.C1 = CFrame.new(-0.5+1.5, 0.8, .9)* CFrame.fromEulerAnglesXYZ(math.rad(290), 0, math.rad(-90))
weld2.C1 = CFrame.new(-1, 0.8, 0.5-1.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
Tool.AnimateValue.Value = "None"
end
end
Tool.AnimateValue.Changed:connect(Animate)
end))
Script7.Name = "LineConnect"
Script7.Parent = Tool0
Script7.Disabled = true
table.insert(cors,sandbox(Script7,function()
wait()
local check = script.Part2
local part1 = script.Part1.Value
local part2 = script.Part2.Value
local parent = script.Par.Value
local color = script.Color
local line = Instance.new("Part")
line.TopSurface = 0
line.BottomSurface = 0
line.Reflectance = .5
line.Name = "Laser"
line.Transparency = 0.6
line.Locked = true
line.CanCollide = false
line.Anchored = true
line.formFactor = 0
line.Size = Vector3.new(0.4,0.4,1)
local mesh = Instance.new("BlockMesh")
mesh.Parent = line
while true do
if (check.Value==nil) then break end
if (part1==nil or part2==nil or parent==nil) then break end
if (part1.Parent==nil or part2.Parent==nil) then break end
if (parent.Parent==nil) then break end
local lv = CFrame.new(part1.Position,part2.Position)
local dist = (part1.Position-part2.Position).magnitude
line.Parent = parent
line.Material = "Neon"
line.BrickColor = color.Value.BrickColor
line.Reflectance = color.Value.Reflectance
line.Transparency = "0.2"
line.CFrame = CFrame.new(part1.Position+lv.lookVector*dist/2)
line.CFrame = CFrame.new(line.Position,part2.Position)
mesh.Scale = Vector3.new(.25,.25,dist)
wait()
end
line:remove()
script:remove()
end))
LocalScript8.Name = "MainScript"
LocalScript8.Parent = Tool0
table.insert(cors,sandbox(LocalScript8,function()
--Physics gun created by Killersoldier45
wait()
tool = script.Parent
lineconnect = tool.LineConnect
object = nil
mousedown = false
found = false
BP = Instance.new("BodyPosition")
BP.maxForce = Vector3.new(math.huge*math.huge,math.huge*math.huge,math.huge*math.huge) --pwns everyone elses bodyposition
BP.P = BP.P*10 --faster movement. less bounceback.
dist = nil
point = Instance.new("Part")
point.Locked = true
point.Anchored = true
point.formFactor = 0
point.Shape = 0
point.Material = 'Neon'
point.BrickColor = BrickColor.new("Toothpaste")
point.Size = Vector3.new(1,1,1)
point.CanCollide = false
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = "Sphere"
mesh.Scale = Vector3.new(.2,.2,.2)
mesh.Parent = point
handle = tool.Shoot
front = tool.Shoot
color = tool.Shoot
objval = nil
local hooked = false
local hookBP = BP:clone()
hookBP.maxForce = Vector3.new(30000,30000,30000)
function LineConnect(part1,part2,parent)
local p1 = Instance.new("ObjectValue")
p1.Value = part1
p1.Name = "Part1"
local p2 = Instance.new("ObjectValue")
p2.Value = part2
p2.Name = "Part2"
local par = Instance.new("ObjectValue")
par.Value = parent
par.Name = "Par"
local col = Instance.new("ObjectValue")
col.Value = color
col.Name = "Color"
local s = lineconnect:clone()
s.Disabled = false
p1.Parent = s
p2.Parent = s
par.Parent = s
col.Parent = s
s.Parent = workspace
if (part2==object) then
objval = p2
end
end
function onButton1Down(mouse)
if (mousedown==true) then return end
mousedown = true
coroutine.resume(coroutine.create(function()
local p = point:clone()
p.Parent = tool
LineConnect(front,p,workspace)
while (mousedown==true) do
p.Parent = tool
if (object==nil) then
if (mouse.Target==nil) then
local lv = CFrame.new(front.Position,mouse.Hit.p)
p.CFrame = CFrame.new(front.Position+(lv.lookVector*1000))
else
p.CFrame = CFrame.new(mouse.Hit.p)
end
else
LineConnect(front,object,workspace)
break
end
wait()
end
p:remove()
end))
while (mousedown==true) do
if (mouse.Target~=nil) then
local t = mouse.Target
if (t.Anchored==false) then
object = t
dist = (object.Position-front.Position).magnitude
break
end
end
wait()
end
while (mousedown==true) do
if (object.Parent==nil) then break end
local lv = CFrame.new(front.Position,mouse.Hit.p)
BP.Parent = object
BP.position = front.Position+lv.lookVector*dist
wait()
end
BP:remove()
object = nil
objval.Value = nil
end
function onKeyDown(key,mouse)
local key = key:lower()
local yesh = false
if (key=="q") then
if (dist>=5) then
dist = dist-5
end
end
if key == "t" then
if (object==nil) then return end
for _,v in pairs(object:children()) do
if v.className == "BodyGyro" then
return nil
end
end
BG = Instance.new("BodyGyro")
BG.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
BG.cframe = CFrame.new(object.CFrame.p)
BG.Parent = object
repeat wait() until(object.CFrame == CFrame.new(object.CFrame.p))
BG.Parent = nil
if (object==nil) then return end
for _,v in pairs(object:children()) do
if v.className == "BodyGyro" then
v.Parent = nil
end
end
object.Velocity = Vector3.new(0,0,0)
object.RotVelocity = Vector3.new(0,0,0)
end
if (key=="e") then
dist = dist+5
end
if (string.byte(key)==27) then
if (object==nil) then return end
local e = Instance.new("Explosion")
e.Parent = workspace
e.Position = object.Position
color.BrickColor = BrickColor.Black()
point.BrickColor = BrickColor.White()
wait(.48)
color.BrickColor = BrickColor.White()
point.BrickColor = BrickColor.Black()
end
if (key=="") then
if not hooked then
if (object==nil) then return end
hooked = true
hookBP.position = object.Position
if tool.Parent:findFirstChild("Torso") then
hookBP.Parent = tool.Parent.Torso
if dist ~= (object.Size.x+object.Size.y+object.Size.z)+5 then
dist = (object.Size.x+object.Size.y+object.Size.z)+5
end
end
else
hooked = false
hookBP.Parent = nil
end
end
if (key=="r") then
if (object==nil) then return end
color.BrickColor = BrickColor.new("Toothpaste")
point.BrickColor = BrickColor.new("Toothpaste")
object.Parent = nil
wait(.48)
color.BrickColor = BrickColor.new("Toothpaste")
point.BrickColor = BrickColor.new("Toothpaste")
end
if (key=="x") then
if (object==nil) then return end
local New = object:clone()
New.Parent = object.Parent
for _,v in pairs(New:children()) do
if v.className == "BodyPosition" or v.className == "BodyGyro" then
v.Parent = nil
end
end
object = New
mousedown = false
mousedown = true
LineConnect(front,object,workspace)
while (mousedown==true) do
if (object.Parent==nil) then break end
local lv = CFrame.new(front.Position,mouse.Hit.p)
BP.Parent = object
BP.position = front.Position+lv.lookVector*dist
wait()
end
BP:remove()
object = nil
objval.Value = nil
end
if (key=="c") then
local Cube = Instance.new("Part")
Cube.Locked = true
Cube.Size = Vector3.new(4,4,4)
Cube.formFactor = 0
Cube.TopSurface = 0
Cube.BottomSurface = 0
Cube.Name = "WeightedStorageCube"
Cube.Parent = workspace
Cube.CFrame = CFrame.new(mouse.Hit.p) + Vector3.new(0,2,0)
for i = 0,5 do
local Decal = Instance.new("Decal")
Decal.Texture = "http://www.roblox.com/asset/?id=2662260"
Decal.Face = i
Decal.Name = "WeightedStorageCubeDecal"
Decal.Parent = Cube
end
end
if (key=="") then
if dist ~= 15 then
dist = 15
end
end
end
function onEquipped(mouse)
keymouse = mouse
local char = tool.Parent
human = char.Humanoid
human.Changed:connect(function() if (human.Health==0) then mousedown = false BP:remove() point:remove() tool:remove() end end)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(function() mousedown = false end)
mouse.KeyDown:connect(function(key) onKeyDown(key,mouse) end)
mouse.Icon = "rbxassetid://2184939409"
end
tool.Equipped:connect(onEquipped)
end))
Part9.Name = "GlowPart"
Part9.Parent = Tool0
Part9.Material = Enum.Material.Neon
Part9.BrickColor = BrickColor.new("Cyan")
Part9.Transparency = 0.5
Part9.Rotation = Vector3.new(0, -89.5899963, 0)
Part9.Shape = Enum.PartType.Cylinder
Part9.Size = Vector3.new(1.20000005, 0.649999976, 2)
Part9.CFrame = CFrame.new(-54.8191681, 0.773548007, -0.0522949994, 0.00736002205, 4.68389771e-11, -0.999974668, 4.72937245e-11, 1, 1.41590961e-10, 0.999974668, 5.09317033e-11, 0.00736002252)
Part9.Color = Color3.new(0.0156863, 0.686275, 0.92549)
Part9.Position = Vector3.new(-54.8191681, 0.773548007, -0.0522949994)
Part9.Orientation = Vector3.new(0, -89.5799942, 0)
Part9.Color = Color3.new(0.0156863, 0.686275, 0.92549)
Script10.Name = "Glow Script"
Script10.Parent = Part9
table.insert(cors,sandbox(Script10,function()
while true do
wait(0.05)
script.Parent.Transparency = .5
wait(0.05)
script.Parent.Transparency = .6
wait(0.05)
script.Parent.Transparency = .7
wait(0.05)
script.Parent.Transparency = .8
wait(0.05)
script.Parent.Transparency = .9
wait(0.05)
script.Parent.Transparency = .8
wait(0.05)
script.Parent.Transparency = .7
wait(0.05)
script.Parent.Transparency = .6
wait(0.05)
script.Parent.Transparency = .5
end
end))
Part11.Name = "GlowPart"
Part11.Parent = Tool0
Part11.Material = Enum.Material.Neon
Part11.BrickColor = BrickColor.new("Cyan")
Part11.Transparency = 0.5
Part11.Rotation = Vector3.new(-89.3799973, -55.7399979, -89.25)
Part11.Size = Vector3.new(0.280000001, 0.25999999, 0.200000003)
Part11.CFrame = CFrame.new(-54.9808807, 0.99843204, 0.799362957, 0.00736002205, 0.562958956, -0.826454222, 4.72937245e-11, 0.826475084, 0.56297338, 0.999974668, -0.00414349511, 0.00608287565)
Part11.Color = Color3.new(0.0156863, 0.686275, 0.92549)
Part11.Position = Vector3.new(-54.9808807, 0.99843204, 0.799362957)
Part11.Orientation = Vector3.new(-34.2599983, -89.5799942, 0)
Part11.Color = Color3.new(0.0156863, 0.686275, 0.92549)
Script12.Name = "Glow Script"
Script12.Parent = Part11
table.insert(cors,sandbox(Script12,function()
while true do