Repository navigation
Expand file tree
/
Copy pathreplayability.lua
More file actions
1060 lines (967 loc) · 30.4 KB
/
Copy pathreplayability.lua
File metadata and controls
1060 lines (967 loc) · 30.4 KB
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
-- Settings
local ReplicateCursor = false -- set it to false if you want cursor in the middle
local FPS = 75.1 -- the fps that replay will play on
--[[
REPLAYABILITY VERSION 1.7.3
(unofficial)
UPDATE INFO:
- Added Count Frames
- Added Start at frame
- Dying and respawning during a replay is now supported
- Uses the game's default gravity instead of 196.2 always
CREDITS:
Wally for the UI Library
Dong for the original script
Plusgiant5 for updating the script
HOW TO USE IT?:
https://www.youtube.com/watch?v=UvaeUzKmqMc&t=70s
]]
loadstring(game:HttpGet("https://raw.githubusercontent.com/plusgiant5/Libraries/main/loadstrings/anti.lua", false))()
-- Services
local ContextActionService = game:GetService("ContextActionService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local UserInputService = game:GetService("UserInputService")
local HttpService = game:GetService("HttpService")
local StarterGui = game:GetService("StarterGui")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local CoreGui = game:GetService("CoreGui")
-- Player
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local PlayerScripts = LocalPlayer:WaitForChild("PlayerScripts")
local Mouse = LocalPlayer:GetMouse()
local Camera = workspace.CurrentCamera
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)
local Humanoid = Character:WaitForChild("Humanoid", 5)
local ZoomMin = LocalPlayer.CameraMinZoomDistance
local ZoomMax = LocalPlayer.CameraMaxZoomDistance
local UseJumpPower = Humanoid.UseJumpPower
local OldJumpHeight = Humanoid.JumpHeight
local NewAnimate = game:GetObjects("rbxassetid://9326088902")[1]
-- Write
local WriteConnection
local PastCameraLocation = CFrame.new()
local PastLocation = CFrame.new()
local RunQueue = {}
local ClimbQueue = {}
local PastZoom = 0
local RecordStart = false -- When initially pressing "T", befor the input wait
local Writing = false -- When recording movement, after the input wait
local Saving = false -- When you have the dialogue option to save/not save a session
local Hooked = false -- When Humanoid is hooked for runspeed/climbspeed
local Dancing = false -- When you is are dancing
local LastMousePositionR = {} -- For setting mouse position after checkpoint
local LastMousePositionW = {} -- For recording ok
local SentDeadSignal = false -- So there is never 2 dead frames next to eachother
-- Read
local RunFunction
local ClimbFunction
local ReadConnection
local Reading = false -- When playing back a recording
local ReadStart = false -- When pressing the read button
local Abort = false -- Temporary pause in playing
local FullAbort = false -- Permanent stop to playing
local ReadTable
local OldState = 0
local Index = 1
local CurrentZoom = 12.5
local Cursor -- Fake cursor!!
local UpdateZoom -- Zoom updating function
local PreviousRunSpeed -- For chatting/pausing/sounds
local PreviousClimbSpeed -- For sounds
local NonCollideTable = {} -- For bricks that are gonna be turned non collidable
local CursorMovement = true -- For first person/leaving first person cursor movement shit
local StartFrame = 1 -- Frame to start reading at, changed by the Start at frame: box
-- Other
local NormalMouseCursor = {
Icon = "rbxasset://textures/Cursors/KeyboardMouse/ArrowFarCursor.png",
Size = UDim2.new(0, 64, 0, 64)
}
local ShiftLockCursor = {
Icon = "rbxasset://textures/MouseLockedCursor.png",
Size = UDim2.new(0, 32, 0, 32)
}
local TempPath = ""
local PlaceId = tostring(game.PlaceId) -- tostring in order to access the files folder
local Folder = isfolder(PlaceId) or makefolder(PlaceId)
local CurrentSavePath = tostring(PlaceId).. "\\Testing.lua"
local CurrentSaveFile = isfile(CurrentSavePath)
local NotificationsBindable = Instance.new("BindableFunction")
local ShowNotifications = true
local IsOldShiftLock = false -- If the game uses an older playermodule, using contextactionservice for shiftlock will not work
local CycAnti = false
local UIShown = true
local Mode = "Write"
local DefaultGravity = workspace.Gravity -- Usually DefaultGravity but some games change it
-- Misc Stuff
if not CurrentSaveFile then
writefile(CurrentSavePath, "[")
end
local ShiftLockAction = ContextActionService:GetAllBoundActionInfo()["MouseLockSwitchAction"]
if not ShiftLockAction then
IsOldShiftLock = true
end
if not mouse1click then
mouse1click = function() end
mousemoveabs = function() end
end
_G.GlobalReading = function()
return Reading
end
-- Functions
local function SendNotification(Message, Time, Func, B1, B2)
if not ShowNotifications then return end
NotificationsBindable.OnInvoke = Func
StarterGui:SetCore("SendNotification", {
Title = "Replayability",
Text = Message,
Duration = Time,
Callback = NotificationsBindable,
Button1 = B1,
Button2 = B2
})
end
local function RejoinGame(Response)
if Response == "YES" then
game:GetService("TeleportService"):Teleport(game.PlaceId)
end
end
-- If ran twice
if Ran then
SendNotification("Replayability is already running. Rejoin?", math.huge, RejoinGame, "YES", "NO")
return
end
local function CanChangeMode()
if Reading then
return false
elseif Writing then
return false
elseif Saving then
return false
end
return true
end
local function Shorten(num) -- shortens a number to x digits after period
if not num then return end
local digits = 8
return tostring(math.floor(num * 10 ^ digits) / (10 ^ digits))
end
local function MoveMouse(X, Y, IsCenter)
if not ReplicateCursor then return end
if IsCenter then
X = Camera.ViewportSize.X/2
Y = math.floor(Camera.ViewportSize.Y/2 - 36)
end
mousemoveabs(X, Y)
VirtualInputManager:SendMouseMoveEvent(X, Y, workspace)
end
local function SetFakeCursorPosition(X, Y)
if Cursor then
local ToSubstract = Cursor.Image == NormalMouseCursor.Icon and 32 or 16
Cursor.Position = UDim2.new(0, X - ToSubstract, 0, Y - ToSubstract)
end
end
local function SendText(Str)
VirtualInputManager:SendTextInputCharacterEvent(Str, workspace)
end
local function SendKey(KeyCode)
VirtualInputManager:SendKeyEvent(true, KeyCode, false, workspace)
end
local function ToggleMouseLock()
if IsOldShiftLock then
SendKey(304) -- 304 is the keycode for leftshift. using virtualinputmanager now
else
ContextActionService:CallFunction("MouseLockSwitchAction", Enum.UserInputState.Begin, game)
end
end
local function CheckMouseLock()
if Mouse.Icon:match("MouseLockedCursor") then
return true
end
return false
end
local function CFrameToTable(CF, IsVector3)
local Old = {CF:GetComponents()}
local New = {}
for Index, Value in pairs(Old) do
New[Index] = Shorten(Value)
end
return New
end
local function TableToCFrame(Tab)
return CFrame.new(unpack(Tab))
end
local function WalkToPoint(Pos) -- Currently Unused
Humanoid.WalkToPoint = Pos
local Terminate = false
delay(4, function()
Terminate = true
end)
while RunService.Stepped:Wait() do
if Terminate then break end
local Magnitude = (HumanoidRootPart.Position - Pos).Magnitude
if Magnitude <= 3 then
break
end
end
return
end
local function HookHumanoid()
local RunConnection
local ClimbConnection
RunConnection = Humanoid.Running:Connect(function(Speed)
if Writing then
table.insert(RunQueue, #RunQueue + 1, Speed)
end
end)
ClimbConnection = Humanoid.Climbing:Connect(function(Speed)
if Writing then
table.insert(ClimbQueue, #ClimbQueue + 1, Speed)
end
end)
Humanoid.Died:Connect(function()
if Reading then
--FullAbort = true
end
RunConnection:Disconnect()
ClimbConnection:Disconnect()
RunConnection = nil
ClimbConnection = nil
end)
end
local function HookFreeFallFunction(Func) -- NOT USED ANYMORE!! MUAHAHAHAHAHAH!! I HAVE SEVERE MENTAL ILLNESS!!
local function FallHandler(o, Bool)
if Humanoid.FloorMaterial ~= Enum.Material.Air and Reading then
if game.GameId == 1055653882 then -- if game is jtoh
if not checkcaller() then -- if not synapse
return -- Does not allow the function to be called if floor material isnt air
end
else
return
end
end
return o(Bool)
end
o1 = hookfunction(Func, function(Bool)
return FallHandler(o1, Bool)
end)
end
local function HookAnimFunction(Func)
local o
o = hookfunction(Func, function(Speed)
if Reading and not checkcaller() then
return -- Does not allow the function to be called if the game tries to play >: ( <-- forget it, i was high on smthn
end
return o(Speed)
end)
end
local function TableCheck(Table) -- anti outmoon
local TableMT = getrawmetatable(Table)
if TableMT and type(rawget(TableMT, "__index")) == "table" then
return true
else
return false
end
end
local function GetAnimationFunctions(IsSecondTry)
local oldanimate = Character:WaitForChild("Animate", 1)
if oldanimate then
oldanimate:Destroy()
end
local n = NewAnimate:Clone()
n.Disabled = true
n.Parent = game.Players.LocalPlayer.Character
getfenv().script = n
local r,e = loadstring(n.Source)
if not r then
error("ERROR IN NEWANIMATE: "..e)
else
r()
end
repeat
wait()
--print("Waiting:",_G.RunFunction,_G.ClimbFunction)
until _G.RunFunction and _G.ClimbFunction
RunFunction = _G.RunFunction
ClimbFunction = _G.ClimbFunction
_G.RunFunction = nil
_G.ClimbFunction = nil
end
local function LoadCharacterSounds()
for _, Table in pairs(getgc(true)) do
if type(Table) == "table" then
for Sound, Func in pairs(Table) do
if typeof(Sound) == "Instance" then
if Sound:IsA("Sound") and type(Func) == "function" then
if Sound.Name == "Running" or Sound.Name == "Climbing" then
local o = Table[Sound]
if islclosure(o) then
local Consts = debug.getconstants(o)
local Script = getfenv(o).script
if Script and typeof(Script) == "Instance" then
if Script.Parent and Script.Name:match("Sounds") then
if table.find(Consts, "Magnitude") then
Table[Sound] = newcclosure(function(DT, Sound, Vel)
local PreviousSpeed = (Sound.Name == "Running" and PreviousRunSpeed) or PreviousClimbSpeed
if Reading and PreviousSpeed then
Sound.Playing = PreviousSpeed > 0.5
else
return o(DT, Sound, Vel)
end
end)
end
end
end
end
end
end
end
end
end
end
end
local function WaitForInput()
local CanReturn = false
local Connection
Connection = UserInputService.InputBegan:Connect(function(Input, GameProcessed)
if not GameProcessed then
CanReturn = true
Connection:Disconnect()
Connection = nil
end
end)
repeat
wait()
if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and not CheckMouseLock() and LastMousePositionR[1] then
MoveMouse(LastMousePositionR[1], LastMousePositionR[2])
end
until CanReturn
return
end
local function SetCharacter()
Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)
Humanoid = Character:WaitForChild("Humanoid", 5)
assert(Humanoid and HumanoidRootPart, "Humanoid or HumanoidRootPart is missing!")
GetAnimationFunctions()
task.delay(1, LoadCharacterSounds)
Hooked = false
end
-- Initial Checks/Variables setting
if LocalPlayer.Character:FindFirstChild("Animate") then
LocalPlayer.Character.Animate:Destroy()
for _,v in pairs(game.Players.LocalPlayer.Character.Humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
end
wait(.5)
GetAnimationFunctions()
task.delay(1, LoadCharacterSounds)
LocalPlayer.CharacterAdded:Connect(SetCharacter)
local ChatGui = PlayerGui:WaitForChild("Chat", 3) -- Replay will be paused/aborted if chat is typing, you can change how long you for it
local ChatBox
if ChatGui then
ChatBox = ChatGui:WaitForChild("Frame"):WaitForChild("ChatBarParentFrame"):FindFirstChild("ChatBar", true)
if ChatBox then
ChatBox.Focused:Connect(function()
if Cursor.Image ~= ShiftLockCursor.Icon and Reading then
Cursor.Image = "rbxasset://textures/Cursors/KeyboardMouse/ArrowCursor.png"
Cursor.Size = UDim2.new(0, 64, 0, 64)
end
Abort = true
end)
ChatBox.FocusLost:Connect(function()
if Cursor.Image ~= ShiftLockCursor.Icon and Reading then
Cursor.Image = NormalMouseCursor.Icon
Cursor.Size = NormalMouseCursor.Size
end
Abort = false
end)
end
end
local function DoDanceClip()
if ChatBox then
SendText("/")
local Rdm = math.random(15, 25)/100
wait(Rdm/2)
if ChatBox:IsFocused() then
SendText("/e dance2")
end
wait(Rdm/2)
SendKey(13) -- Enter key
wait((2 + 1/6 + 1/6) - Rdm)
end
end
LocalPlayer.Chatted:Connect(function(Msg) -- For /e dance2
if Msg:match("/e dance2") then
Dancing = true
end
end)
UserInputService.InputBegan:Connect(function(Input, GameProcessed)
if not GameProcessed and Reading then
if Input.UserInputType == Enum.UserInputType.Keyboard then
local Pressed = Input.KeyCode
if Pressed == Enum.KeyCode.L then
FullAbort = true
SendNotification("Replay has been terminated.", 3)
end
end
end
end)
local JTOHPlayerScripts = PlayerScripts:FindFirstChild("PlayerScripts")
if JTOHPlayerScripts then
local Limiter = JTOHPlayerScripts:FindFirstChild("Framerate Limiter")
if Limiter then
Limiter.Disabled = true
end
end
-- Cursor GUI
local CursorGui = Instance.new("ScreenGui")
if syn then
syn.protect_gui(CursorGui)
end
CursorGui.Name = HttpService:GenerateGUID(false)
CursorGui.Parent = game:GetService("CoreGui")
Cursor = Instance.new("ImageLabel")
Cursor.Name = HttpService:GenerateGUID(false)
Cursor.Image = NormalMouseCursor.Icon
Cursor.Size = NormalMouseCursor.Size
Cursor.BorderSizePixel = 0
Cursor.BackgroundTransparency = 1
Cursor.Visible = false
Cursor.Parent = CursorGui
-- Zoom Functions
local Self -- Utilized for module zoom functions
local ZoomSpring
local EndLoop = false
local function ResetZoom()
LocalPlayer.CameraMinZoomDistance = ZoomMin
LocalPlayer.CameraMaxZoomDistance = ZoomMax
end
local function SetZoom(Studs)
local SetToOne = false
if (Studs < 1 and Studs > 0.51) or Studs < 0.49 then
SetToOne = true
end
LocalPlayer.CameraMinZoomDistance = (SetToOne and 1) or Studs
LocalPlayer.CameraMaxZoomDistance = (SetToOne and 1) or Studs
ResetZoom()
end
for _, Table in pairs(getgc(true)) do -- Self Table
if type(Table) == "table" then
pcall(function()
if TableCheck(Table) then
if not Self then
local ModuleFunction = Table.EnterFirstPerson
if ModuleFunction and type(ModuleFunction) == "function" then
local ModuleScript = getfenv(ModuleFunction).script
if typeof(ModuleScript) == "Instance" then
if ModuleScript.Name == "ClassicCamera" then
Self = Table
end
end
end
end
if not ZoomSpring then
local ZoomMinValue = Table.minValue
local ModuleFunction_2 = Table.Step
if ZoomMinValue and ModuleFunction_2 and type(ModuleFunction_2) == "function" then
local ModuleScript_2 = getfenv(ModuleFunction_2).script
if typeof(ModuleScript_2) == "Instance" then
if ModuleScript_2.Name == "ZoomController" then
ZoomSpring = Table
end
end
end
end
end
end)
if Self and ZoomSpring then
break
end
end
end
assert(Self and ZoomSpring, "Table variable(s) could not be located.")
for _, Table in pairs(debug.getregistry()) do
if type(Table) == "table" then
if TableCheck(Table) then
local ZoomFunc = Table.SetCameraToSubjectDistance -- Normal Zoom
if ZoomFunc and type(ZoomFunc) == "function" then
local ModuleScript = getfenv(ZoomFunc).script
if typeof(ModuleScript) == "Instance" then
if ModuleScript.Name == "BaseCamera" then
UpdateZoom = function(Studs)
CurrentZoom = Studs
ZoomSpring.x = Studs or 12.5
if Studs <= 0.52 and not Self.inFirstPerson then
MoveMouse(nil, nil, true) -- DONG IDFK WHAT IM DOING MOMENT
Self:EnterFirstPerson()
CursorMovement = false
MoveMouse(nil, nil, true)
wait(0.1)
mouse1click()
elseif Studs > 0.52 and Self.inFirstPerson then
Self:LeaveFirstPerson()
CursorMovement = true
end
if Studs <= 0.52 or Studs >= 1 then
return ZoomFunc(Self, Studs)
end
end
end
end
end
local PopperZoomFunc = Table.Update -- Poppercam Zoom
if PopperZoomFunc and type(PopperZoomFunc) == "function" then
local ModuleScript = getfenv(PopperZoomFunc).script
if typeof(ModuleScript) == "Instance" then
if ModuleScript.Name == "Poppercam" then
for _, Upvalue in pairs(debug.getupvalues(PopperZoomFunc)) do
local CurrentTable = Upvalue
local o = CurrentTable.Update
CurrentTable.Update = function(self, ...)
if Reading then
return CurrentZoom
else
return o(self, ...)
end
end
break
end
end
end
end
end
end
end
assert(UpdateZoom, "Could not find zoom updating function")
-- UI Initilializing
local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/plusgiant5/Libraries/main/loadstrings/wallyuilib.lua", true))()
local MainWindow = Library:CreateWindow("Replayability")
MainWindow:Bind("Hide Gui", { -- Main Section
flag = "ToggleUI",
kbonly = true,
default = Enum.KeyCode.U
}, function()
local ScreenGui = game:GetService("CoreGui").ScreenGui
if Reading and ScreenGui.Enabled == false then return end
ScreenGui.Enabled = not UIShown
UIShown = not UIShown
SendNotification("Changed UI Visibility", 3)
end)
MainWindow:Toggle("Show Notifications", {flag = "ToggleNotifs"}, function(Bool)
ShowNotifications = Bool
end)
pcall(function() -- shit ui library
MainWindow.flags.ToggleNotifs = true
game:GetService("CoreGui"):FindFirstChild("Show Notifications", true):WaitForChild("Checkmark", 3).Text = "✓"
end)
MainWindow:Dropdown("Mode", {
location = shared;
flag = "Mode";
list = {
"Write",
"Read"
}
}, function(ChosenMode)
if not CanChangeMode() then
print("cant change mode now")
return
end
Mode = ChosenMode
ResetZoom()
SendNotification("Mode changed to: ".. ChosenMode, 3)
end)
MainWindow:Section("Write") -- Write Section
local function AppendToMain() -- Writing to files
local ToAppend = TempPath
appendfile(CurrentSavePath, ToAppend)
end
local function AppendToTemp(Tab)
local Encoded = HttpService:JSONEncode(Tab)
TempPath ..= Encoded..","
end
MainWindow:Bind("Begin Replay", {
flag = "BeginReplay",
kbonly = true,
default = Enum.KeyCode.T
}, function()
if Mode ~= "Write" or Saving or RecordStart then return end
if Writing then
Writing = false
Saving = true
local NewLocation = HumanoidRootPart.CFrame
local NewCamCF = Camera.CFrame
local NewCamFC = Camera.Focus
local NewZoom = (NewCamCF.Position - NewCamFC.Position).Magnitude
local responded = false
local inputconnection
function answer(Text)
if not responded then
responded = true
if Text == "YES (p)" then
print("Saving...")
LastMousePositionR = LastMousePositionW
PastLocation = NewLocation
PastCameraLocation = NewCamCF
PastZoom = NewZoom
AppendToMain()
TempPath = ""
SendNotification("Saved", 2)
else
print("Discarded save.")
TempPath = ""
HumanoidRootPart.CFrame = PastLocation
Camera.CFrame = PastCameraLocation
if PastZoom ~= 0 then
SetZoom(PastZoom)
end
ResetZoom()
SendNotification("Discarded", 2)
end
end
Saving = false
if inputconnection then
inputconnection:Disconnect()
end
end
inputconnection = UserInputService.InputBegan:Connect(function(k,v)
if v then
return
end
if k.KeyCode == Enum.KeyCode.F then
answer("NO (f)")
elseif k.KeyCode == Enum.KeyCode.P then
answer("YES (p)")
end
end)
SendNotification("Save Replay?", 15, answer, "NO (f)", "YES (p)")
else
repeat wait() until Humanoid.Parent -- Cuz idk??!?!?
RecordStart = true
SendNotification("Waiting for input.", 2)
WaitForInput()
Writing = true
RecordStart = false
SendNotification("Recording has started.", 3)
end
end)
MainWindow:Bind("Goto Checkpoint", {
flag = "GotoCheckpoint",
kbonly = true,
default = Enum.KeyCode.Y
}, function()
if Mode ~= "Write" or Saving then return end
HumanoidRootPart.CFrame = PastLocation
Camera.CFrame = PastCameraLocation
SetZoom(PastZoom)
ResetZoom()
if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and not CheckMouseLock() and LastMousePositionR[1] then
MoveMouse(LastMousePositionR[1], LastMousePositionR[2])
end
end)
MainWindow:Section("Read") -- Read Section
MainWindow:Button("Start", function()
if Reading or Mode ~= "Read" or RecordStart or ReadStart then return end
ReadStart = true
SendNotification("Reading is starting in 2 seconds.", 3)
delay(2, function()
Reading = true
ReadStart = false
end)
end)
MainWindow:Section("Other") -- Other Section
MainWindow:Button("Disable Killbricks", function()
local n = 0
for _,v in pairs(workspace:GetDescendants()) do
if (v.Name == "kills" or v.Name == "instakills" or v.Name == "poisons" or v.Name == "ouch") and v.Parent.CanTouch then
v.Parent.CanTouch = false
n = n + 1
end
end
SendNotification("Disabled "..tostring(n).." killbricks.", 3)
end)
MainWindow:Button("Count Frames", function()
local frames = #HttpService:JSONDecode(readfile(PlaceId.."\\Testing.lua").."1]")
SendNotification("This replay has "..tostring(frames).." frames ("..tostring(math.floor(frames/60*100+.5)/100).." seconds long at constant 60 fps)", 10)
end)
MainWindow:Box("Start at frame: ", {default = "0"}, function(frame)
StartFrame = tonumber(frame)
Index = StartFrame
SendNotification("Reading will now start at frame "..frame, 3)
end)
-- Main Loops
-- WRITE
local function Write()
while true do
if not Writing or Saving then
wait()
else
local t = tick()
local StateTypeValue = Humanoid and Humanoid.Parent and Humanoid:GetState().Value
if not SentDeadSignal then
if not Hooked then
HookHumanoid()
Hooked = true
end
local s,e = pcall(function()
Character.Head.CanCollide = true
local CamCFrame = Camera.CFrame
local CamFocus = Camera.Focus
local Zoom = (CamCFrame.Position - CamFocus.Position).Magnitude
local RunSpeed = RunQueue[1]
local ClimbSpeed = ClimbQueue[1]
local WriteTable = {}
WriteTable[1] = CFrameToTable(HumanoidRootPart.CFrame)
WriteTable[2] = CFrameToTable(CamCFrame)
WriteTable[3] = Zoom
WriteTable[4] = Shorten(RunSpeed) or false
if RunSpeed then
table.remove(RunQueue, 1)
end
WriteTable[5] = Shorten(ClimbSpeed) or false
if ClimbSpeed then
table.remove(ClimbQueue, 1)
end
WriteTable[6] = CheckMouseLock()
WriteTable[7] = StateTypeValue
local MousePosition = {
Mouse.X, Mouse.Y
}
WriteTable[8] = MousePosition
LastMousePositionW = MousePosition
WriteTable[9] = Dancing
if Dancing then
Dancing = false
end
AppendToTemp(WriteTable)
end)
if not s then
print(e)
end
end
RunService.Stepped:Wait()
repeat until (t + (1/FPS)) < tick()
print(StateTypeValue)
if StateTypeValue == 15 and not SentDeadSignal then -- Dead
--print("w1")
SentDeadSignal = true
else
if StateTypeValue and SentDeadSignal then -- make sure the humanoid exists, and SentDeadSignal isnt already false
SentDeadSignal = false
--print("w2")
end
end
end
end
end
coroutine.wrap(Write)()
-- READ
local function Read()
while true do
if not Reading then
wait()
else
local t = tick()
if not ReadTable then
local Success, Return = pcall(function()
return HttpService:JSONDecode(readfile(PlaceId.. "\\Testing.lua") .. "1]")--[1]
end)
if not Success then
Reading = false
error("Error parsing the JSON file")
end
if Humanoid.Health <= 0 then
Reading = false
end
ReadTable = Return
Humanoid.AutoRotate = false
Humanoid.Died:Connect(function()
if Reading then
--FullAbort = true
end
end)
local CharAddedConnection
CharacterAddedConnection = LocalPlayer.CharacterAdded:Connect(function()
if Reading then
--FullAbort = true
CharacterAddedConnection:Disconnect()
end
end)
UserInputService.MouseIconEnabled = not ReplicateCursor
Cursor.Visible = ReplicateCursor
--local FirstLocation = ReadTable[1][1]
--WalkToPoint(Vector3.new(FirstLocation.X, FirstLocation.Y, FirstLocation.Z))
end
local CurrentReadTable = ReadTable[Index]
if not CurrentReadTable or type(CurrentReadTable) ~= "table" or FullAbort then
local LastIndex = ReadTable[Index - 1]
if LastIndex then
local LastMousePositionEnd = LastIndex[8]
if LastMousePositionEnd and LastMousePositionEnd[1] then
MoveMouse(LastMousePositionEnd[1], LastMousePositionEnd[2])
end
end
if Cursor then
Cursor.Visible = false
end
UserInputService.MouseIconEnabled = true
Reading = false
FullAbort = false
ReadTable = nil
PreviousRunSpeed = nil
Index = StartFrame
workspace.Gravity = DefaultGravity
Humanoid.AutoRotate = true
Humanoid.UseJumpPower = UseJumpPower -- Sets it to whatever the game set it to by default
Humanoid.JumpHeight = OldJumpHeight
CurrentZoom = 0
continue
end
workspace.Gravity = 0
if Abort then
RunFunction(0, true)
workspace.Gravity = DefaultGravity
repeat wait() until not Abort
wait(math.random(15, 25)/10)
if PreviousRunSpeed then
RunFunction(PreviousRunSpeed, true)
end
end
if Humanoid.UseJumpPower then
Humanoid.UseJumpPower = false
Humanoid.JumpHeight = 0
end
local HumanoidRootPartLocation = TableToCFrame(CurrentReadTable[1])
local CameraLocation = TableToCFrame(CurrentReadTable[2])
local Zoom = CurrentReadTable[3]
local RunSpeed = tonumber(CurrentReadTable[4])
local ClimbSpeed = tonumber(CurrentReadTable[5])
local IsMouseLocked = CurrentReadTable[6]
local StateTypeValue = CurrentReadTable[7]
local MousePosition = (ReplicateCursor and CurrentReadTable[8]) or nil
local DanceClipping = CurrentReadTable[9] or (CurrentReadTable[8] == true and CurrentReadTable[8])
local _, YAxisCameraRotation = CameraLocation:ToEulerAnglesYXZ()
local XAxisCharacterRotation, YAxisCharacterRotation, ZAxisCharacterRotation = HumanoidRootPartLocation:ToEulerAnglesYXZ()
Camera.CFrame = CameraLocation
UpdateZoom(Zoom)
HumanoidRootPart.Velocity = Vector3.new()
if (IsMouseLocked or (Zoom <= 0.51 and Zoom >= 0.49)) and StateTypeValue ~= 0 and StateTypeValue ~= 2 then -- Shiftlocked, isfirstperson, isfallingdown and isgettingbackup respectively
HumanoidRootPart.CFrame = HumanoidRootPartLocation * CFrame.Angles(0, -YAxisCharacterRotation + YAxisCameraRotation, 0)
else
HumanoidRootPart.CFrame = HumanoidRootPartLocation
end
for _, BasePart in pairs(Character:GetChildren()) do
if BasePart:IsA("BasePart") then
if BasePart.CanCollide and StateTypeValue == 5 then
--BasePart.CanCollide = false
end
end
end
--[[ OLD GRAVITY MODIFIER
if StateTypeValue == 5 and workspace.Gravity ~= 0 then
workspace.Gravity = 0
elseif StateTypeValue ~= 5 and workspace.Gravity ~= 196.2 then
workspace.Gravity = 196.2
end
]]
if MousePosition and MousePosition[1] then
SetFakeCursorPosition(MousePosition[1], MousePosition[2])
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
VirtualInputManager:SendMouseMoveEvent(MousePosition[1], MousePosition[2], workspace)
end
end
--[[ OLD MOUSE POSITIONING
if MousePosition and UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and CursorMovement and not CheckMouseLock() and MousePosition[1] then
MoveMouse(MousePosition[1], MousePosition[2])
elseif UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
VirtualInputManager:SendMouseMoveEvent(MousePosition[1], MousePosition[2], workspace)
end
]]
if (IsMouseLocked and not CheckMouseLock()) or (not IsMouseLocked and CheckMouseLock()) then
ToggleMouseLock()
mouse1click()
end
local CurrentLocked = CheckMouseLock()
Cursor.Image = CurrentLocked and ShiftLockCursor.Icon or NormalMouseCursor.Icon
Cursor.Size = CurrentLocked and ShiftLockCursor.Size or NormalMouseCursor.Size
--[[ ANTI SERVER-SIDED DETECTION
if RunSpeed then
HumanoidRootPart.Velocity = Vector3.new(RunSpeed/2, 0, 0)
else
HumanoidRootPart.Velocity = Vector3.new(HumanoidRootPart.Velocity.X, 0, 0)
end
]]
if StateTypeValue ~= OldState then
if StateTypeValue == 3 then -- Jumping
Humanoid.Jump = true
else
if StateTypeValue == 15 then
-- press keys Esc+R+Enter then reset gravity
keypress(0x1B)
wait()
keyrelease(0x1B)
wait(math.random(15,27)/100)
keypress(0x52)
wait()
keyrelease(0x52)
wait(math.random(15,27)/100)
keypress(0x0D)
wait()
keyrelease(0x0D)
wait(math.random(15,27)/100)
workspace.Gravity = DefaultGravity
end
Humanoid:ChangeState(StateTypeValue)