This repository was archived by the owner on Jan 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFreeScript.lua
More file actions
1631 lines (1328 loc) · 62.8 KB
/
FreeScript.lua
File metadata and controls
1631 lines (1328 loc) · 62.8 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
--!strict
-- made by Zynic
--------------------------------VARIABLES SECTION OF THE CODE-----------------------------------
------------------------------------------------------------------------------------------------
local Octree
local library
local Iris
if httpget then
Octree = loadstring(httpget("https://raw.githubusercontent.com/Sleitnick/rbxts-octo-tree/main/src/init.lua", true))()
library = loadstring(httpget("https://raw.githubusercontent.com/Zyn-ic/MM2-AutoFarm/refs/heads/main/UI-Library/XSX.lua", true))()
Iris = loadstring(httpget("https://raw.githubusercontent.com/x0581/Iris-Exploit-Bundle/2.0.4/bundle.lua"))().Init(game.CoreGui)
else
game:GetService("StarterGui"):SetCore("SendNotification", { Title = "Using Old Method", Text = "using discontinued 'game:HttpGet'", Duration = 4 })
Octree = loadstring(game:HttpGet("https://raw.githubusercontent.com/Sleitnick/rbxts-octo-tree/main/src/init.lua", true))()
library = loadstring(game:HttpGet("https://raw.githubusercontent.com/Zyn-ic/MM2-AutoFarm/refs/heads/main/UI-Library/XSX.lua", true))()
Iris = loadstring(game:HttpGet("https://raw.githubusercontent.com/x0581/Iris-Exploit-Bundle/2.0.4/bundle.lua"))().Init(game.CoreGui)
end
--local WayPointManager = loadstring(httpget("https://raw.githubusercontent.com/Zyn-ic/MM2-AutoFarm/refs/heads/main/Iris-Functions/WayPointManager", true))()
local Notif = library:InitNotifications()
library.rank = "developer"
local rt = {} -- Removable table
rt.__index = rt
rt.octree = Octree.new()
rt.Players = game:GetService("Players")
rt.RunService = game:GetService("RunService")
rt.CoreGui = game:GetService("CoreGui")
rt.TeleportService = game:GetService("TeleportService")
rt.HttpService = game:GetService("HttpService")
rt.Camera = game:GetService("Workspace").CurrentCamera
rt.IWPM = false :: boolean-- Iris WayPointManager
rt.player = rt.Players.LocalPlayer :: Player
rt.sheriff = nil :: Player
rt.Murderer = nil :: Player
rt.PreviousMurderer = nil :: Player
rt.Viewing = false :: boolean
rt.RoleTracker1 = nil :: RBXScriptConnection
rt.RoleTracker2 = nil :: RBXScriptConnection
rt.WeaponTracker1 = nil :: RBXScriptConnection
rt.WeaponTracker2 = nil :: RBXScriptConnection
rt.Joined = nil :: RBXScriptConnection
rt.Left = nil :: RBXScriptConnection
rt.viewChanged = nil :: RBXScriptConnection
rt.viewDiedFunc = nil :: RBXScriptConnection
rt.Map = nil :: Model
rt.flingActive = false :: boolean
rt.refresh = nil :: (boolean?) -> ()
rt.HitboxSize = nil :: number
rt.espON = false :: boolean
rt.playerESP = {}
rt.AutoFarmOn = false
rt.coinContainer = nil
rt.Material = Enum.Material.Ice :: EnumItem
rt.TpBackToStart = true :: boolean
rt.Uninterrupted = false :: boolean
rt.radius = 200 :: number -- Radius to search for coins
rt.walkspeed = 35 :: number -- speed at which you will go to a coin measured in walkspeed
rt.touchedCoins = {} -- Table to track touched coins
rt.positionChangeConnections = setmetatable({}, { __mode = "v" }) -- Weak table for connections
rt.Added = nil :: RBXScriptConnection
rt.Removing = nil :: RBXScriptConnection
rt.start = nil :: thread
rt.UserDied = nil :: RBXScriptConnection
rt.Settings = {}
rt.waypoint = nil :: CFrame
rt.Settings.WayPoints = {}
---------------------------------------LOCAL FUNCTIONS-------------------------------------------
-------------------------------------------------------------------------------------------------
-- Function to set a palyer Collision Status
-- local function setCharacterCollision (character: Model, state:boolean)
-- for _, part in pairs(character:GetDescendants()) do
-- if part:IsA("BasePart") or part:IsA("MeshPart") then
-- part.CanCollide = state
-- end
-- end
-- end
-- Function to teleport to a player
local function TeleportToPlayer(targetPlayer)
if rt:Character() and rt:Character():FindFirstChild("HumanoidRootPart") and targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
rt:Character():PivotTo(targetPlayer.Character:GetPivot())
end
end
-- Function to disconnect ESP for a player
local function RemovePlayerESP(player)
if rt.playerESP[player] then
rt.playerESP[player].button.Parent:Destroy()
rt.Disconnect(rt.playerESP[player].connection1)
rt.Disconnect(rt.playerESP[player].connection2)
rt.Disconnect(rt.playerESP[player].connection3)
rt.playerESP[player] = nil
end
end
-- Function to create the UI for a player's ESP
local function CreatePlayerESP(player)
if rt.espON == false then return end
if rt.playerESP[player] then return end -- Prevent duplicate ESPs
-- Create ScreenGui for the ESP
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "CorePosition_" .. player.Name
screenGui.Parent = game:GetService("CoreGui")
-- Create a button for the ESP
local button = Instance.new("TextButton")
button.Size = UDim2.new(0, 25, 0, 25) -- Size of the button
button.Text = "👤"
button.BackgroundColor3 = Color3.fromRGB(94, 94, 94) -- Default grey color
button.TextSize = 14
button.Visible = false
button.Parent = screenGui
Instance.new("UICorner").Parent = button -- Rounded corners
-- Track the button and connection
rt.playerESP[player] = { button = button, connection1 = nil, connection2 = nil, connection3 = nil }
local lastClick = 0
local holdingStartTime = 0
local holding = false
button.MouseButton1Down:Connect(function()
holdingStartTime = tick()
holding = true
-- Start a task to check if the button is held for 1.5 seconds
task.spawn(function()
while holding do
if tick() - holdingStartTime >= 0.3 then
TeleportToPlayer(player) -- Teleport after 1.5 seconds
holding = false -- Stop the loop
break
end
task.wait()
end
end)
end)
button.MouseButton1Up:Connect(function()
holding = false -- Stop checking when the button is released
local now = tick()
-- Handle button double-click for removing ESP
if now - lastClick < 0.5 then
RemovePlayerESP(player)
end
lastClick = now -- Update last click time
end)
-- Update button's position and properties each frame
rt.playerESP[player].connection1 = rt.RunService.RenderStepped:Connect(function()
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
local character = player.Character
local rootPart = character.HumanoidRootPart
local screenPoint = rt.Camera:WorldToScreenPoint(rootPart.Position)
-- Check if the player is on screen
if screenPoint.Z > 0 then
button.Position = UDim2.new(0, screenPoint.X - button.Size.X.Offset / 2, 0, screenPoint.Y - button.Size.Y.Offset / 2)
button.Visible = true
-- Update button text and color based on role
if rt.Murderer ~= nil and player.Name == rt.Murderer.Name then
button.Text = "🔪"
button.BackgroundColor3 = Color3.fromRGB(184, 88, 88) -- Red
elseif rt.sheriff ~= nil and player.Name == rt.sheriff.Name then
button.Text = "🔫"
button.BackgroundColor3 = Color3.fromRGB(99, 99, 168) -- Blue
else
button.Text = "👤"
button.BackgroundColor3 = Color3.fromRGB(94, 94, 94) -- Grey
end
else
button.Visible = false
end
else
-- Update button to "dead" state
button.Text = "💀"
button.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Black
button.Visible = true
end
end)
-- Update ESP when the player dies or respawns
rt.playerESP[player].connection2 = player.CharacterRemoving:Connect(function()
button.Text = "💀"
button.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Black
end)
rt.playerESP[player].connection3 = player.CharacterAdded:Connect(function()
task.wait()
button.Text = "👤"
button.BackgroundColor3 = Color3.fromRGB(94, 94, 94) -- Grey
-- Refresh roles dynamically
if rt.Murderer ~= nil and player.Name == rt.Murderer.Name then
button.Text = "🔪"
button.BackgroundColor3 = Color3.fromRGB(184, 88, 88) -- Red
elseif rt.sheriff ~= nil and player.Name == rt.sheriff.Name then
button.Text = "🔫"
button.BackgroundColor3 = Color3.fromRGB(99, 99, 168) -- Blue
end
end)
end
-- Function to refresh ESP roles dynamically
local function RefreshRoles(newMurderer, newSheriff)
local murdererName = newMurderer or ""
local sheriffName = newSheriff or ""
-- Refresh all existing ESP buttons
for player, espData in pairs(rt.playerESP) do
local button = espData.button
if player.Name == murdererName then
button.Text = "🔪"
button.BackgroundColor3 = Color3.fromRGB(184, 88, 88) -- Red
elseif player.Name == sheriffName then
button.Text = "🔫"
button.BackgroundColor3 = Color3.fromRGB(99, 99, 168) -- Blue
else
button.Text = "👤"
button.BackgroundColor3 = Color3.fromRGB(94, 94, 94) -- Grey
end
end
end
local function createHitboxForPlayers(players, sizeArg, Trans:number ?)
for _, v in pairs(players) do
if v.Name == rt.player.Name then continue end
if v.Character and v.Character:FindFirstChild('HumanoidRootPart') then
local Size = Vector3.new(sizeArg, sizeArg, sizeArg)
local Root = v.Character:FindFirstChild('HumanoidRootPart')
if Root:IsA("BasePart") then
if not sizeArg or sizeArg == 1 then
Root.Size = Vector3.new(2, 2, 1)
Root.Transparency = Trans or 0.3
Root.CanCollide = false;
else
--reset hitbox
if sizeArg == 0 then Root.Size = rt:Character().PrimaryPart.Size; Root.Transparency = Trans or 1; Root.CanCollide = true; continue end
-- set hitbox
Root.Size = Size
Root.Transparency = Trans or 0.3
Root.CanCollide = false;
end
end
end
end
end
---------------------------------------ATUOFARM SECTION--------------------------------------
local collectCoins
local function AutoFarmCleanUp()
-- Check if the table is empty
if next(rt.positionChangeConnections) == nil then
rt.AutoFarmOn = false
print("No items in positionChangeConnections")
return true
end
rt.AutoFarmOn = false
coroutine.yield(rt.start)
coroutine.close(rt.start)
if coroutine.status(rt.start) == "suspended" then
coroutine.yield(rt.start)
coroutine.close(rt.start)
end
-- Disconnect all connections
for _, connection in pairs(rt.positionChangeConnections) do
rt.Disconnect(connection)
end
rt.Disconnect(rt.Added)
rt.Disconnect(rt.Removing)
-- Notify and clean up
Notif:Notify("Removing cached instances for AutoFarm", 1.5, "success")
table.clear(rt.touchedCoins)
table.clear(rt.positionChangeConnections)
task.wait(1)
rt.start = coroutine.create(collectCoins)
return true
end
-- Function to check if a coin has been touched
local function isCoinTouched(coin)
return rt.touchedCoins[coin]
end
-- Function to mark a coin as touched
local function markCoinAsTouched(coin)
if not rt then return end
rt.touchedCoins[coin] = true
local node = rt.octree:FindFirstNode(coin)
if node then
rt.octree:RemoveNode(node)
end
end
-- Function to track touch interactions
local function setupTouchTracking(coin)
local touchInterest = coin:FindFirstChildWhichIsA("TouchTransmitter")
if touchInterest then
local connection
connection = touchInterest.AncestryChanged:Connect(function(_, parent)
if not rt then connection:Disconnect() return end
if parent == nil then
-- TouchInterest removed; mark the coin as touched
markCoinAsTouched(coin)
rt.Disconnect(connection)
end
end)
rt.positionChangeConnections[coin] = connection
end
end
local function setupPositionTracking(coin: MeshPart, LastPositonY: number)
local connection
connection = coin:GetPropertyChangedSignal("Position"):Connect(function()
-- Check if the Y position has changed
local currentY = coin.Position.Y
if LastPositonY and LastPositonY ~= currentY then
-- Remove the coin from the octree as it has been moved
markCoinAsTouched(coin)
rt.Disconnect(connection)
coin:Destroy()
return
end
end)
rt.positionChangeConnections[coin] = connection
end
-- Function to populate the Octree with coins
local function populateOctree()
rt.octree:ClearAllNodes() -- Clear previous nodes
for _, descendant in pairs(rt.coinContainer:GetDescendants()) do
if descendant:IsA("TouchTransmitter") then --and descendant.Material == rt.Material then
local parentCoin = descendant.Parent
if not isCoinTouched(parentCoin) then
rt.octree:CreateNode(parentCoin.Position, parentCoin)
setupTouchTracking(parentCoin)
end
setupPositionTracking(parentCoin, parentCoin.Position.Y)
end
end
rt.Added = rt.coinContainer.DescendantAdded:Connect(function(descendant)
if descendant:IsA("TouchTransmitter") then --and descendant.Material == rt.Material then
local parentCoin = descendant.Parent
if not isCoinTouched(parentCoin) then
rt.octree:CreateNode(parentCoin.Position, parentCoin)
setupTouchTracking(parentCoin)
setupPositionTracking(parentCoin, parentCoin.Position.Y)
end
end
end)
rt.Removing = rt.coinContainer.DescendantRemoving:Connect(function(descendant)
if descendant:IsA("TouchTransmitter") and descendant.Parent.Name == "Coin_Server" then
local parentCoin = descendant.Parent
if isCoinTouched(parentCoin) then
markCoinAsTouched(parentCoin)
end
end
end)
end
local function moveToPositionSlowly(targetPosition: Vector3, duration: number)
rt.humanoidRootPart = rt:Character().PrimaryPart
local startPosition = rt.humanoidRootPart.Position
local startTime = tick()
while true do
local elapsedTime = tick() - startTime
local alpha = math.min(elapsedTime / duration, 1)
rt:Character():PivotTo(CFrame.new(startPosition:Lerp(targetPosition, alpha)))
if alpha >= 1 then
task.wait(0.2)
break
end
task.wait() -- Small delay to make the movement smoother
end
end
-- Function to collect coins
collectCoins = function ()
-- Ensure CoinContainer exists
rt.coinContainer = rt:Map():FindFirstChild("CoinContainer")
rt.waypoint = rt:Character():GetPivot()
local check = rt:MainGUI():WaitForChild("Game").CoinBags.Container.SnowToken.CurrencyFrame.Icon.Coins
local price = "40"
if rt:IsElite() then price = "50" end
-- Populate Octree
populateOctree()
while rt.AutoFarmOn do
if check.Text == price then
Notif:Notify("Full Bag", 2, "success")
break
end
-- Find nearest coin
local nearestNode = rt.octree:GetNearest(rt:Character().PrimaryPart.Position, rt.radius, 1)[1]
if nearestNode then
local closestCoin = nearestNode.Object
if not isCoinTouched(closestCoin) then
local closestCoinPosition = closestCoin.Position
local distance = (rt:Character().PrimaryPart.Position - closestCoinPosition).Magnitude
local duration = distance / rt.walkspeed -- Default walk speed is 26 studs/sec
-- Move to the coin
moveToPositionSlowly(closestCoinPosition, duration)
-- Mark coin as touched and clean up
markCoinAsTouched(closestCoin)
task.wait(0.2) -- Ensure touch is registered
end
else
task.wait(1) -- No coins; retry after delay
end
end
if rt.TpBackToStart then
rt:Character():PivotTo(rt.waypoint)
end
AutoFarmCleanUp()
end
local function ToggleAutoFarm(value : boolean)
if not value then
return AutoFarmCleanUp()
end
if not rt:CheckIfGameInProgress() then Notif:Notify("Map must be loaded to use Autofarm", 2, "error") return false end
if not rt:CheckIfPlayerWasInARound() then Notif:Notify("You need to be in a round or have played a round to use the autofarm", 5, "error") return false end
if not rt.Murderer then Notif:Notify("No Murderer found to satisfy: Round in Progress", 4, "information") return false end
local isAlive = rt:CheckIfPlayerIsInARound()
local OldState = rt.Uninterrupted
local IsMurderer = rt.player.Name == rt.Murderer.Name
--if the player is the murderer and has on rt.Uninterrupted
if rt.Uninterrupted and IsMurderer then rt.Uninterrupted = false; IsMurderer = not IsMurderer end
if rt.Uninterrupted then
rt:Character():FindFirstChildWhichIsA("Humanoid"):ChangeState(Enum.HumanoidStateType.Dead)
repeat task.wait() until rt.player.CharacterAdded:Wait() --rt.player:HasAppearanceLoaded()
task.wait(1)
TeleportToPlayer(rt.Murderer)
--start autofarm
Notif:Notify("Uninterrupted made it all the way", 4, "alert")
rt.AutoFarmOn = true
coroutine.resume(rt.start)
else
if rt.Uninterrupted ~= OldState then rt.Uninterrupted = OldState end
if IsMurderer then
if not isAlive then Notif:Notify("Died before you could start? sad ngl ", 4, "alert") return false end
--start autofarm
Notif:Notify("Collect sum coins Murderer!", 4, "alert")
rt.AutoFarmOn = true
coroutine.resume(rt.start)
else
--start autofarm
if not isAlive then TeleportToPlayer(rt.Murderer) end
Notif:Notify("Normal made it all the way", 4, "alert")
rt.AutoFarmOn = true
coroutine.resume(rt.start)
end
end
return true
end
--------------------------------FUNCTIONS SECTION OF THE CODE-----------------------------------
------------------------------------------------------------------------------------------------
function rt:MainGUI () : (ScreenGui)
return rt.player.PlayerGui.MainGUI or rt.player.PlayerGui:WaitForChild("MainGUI")
end
function rt:Character () : (Model)
return self.player.Character or self.player.CharacterAdded:Wait()
end
function rt.Disconnect (connection:RBXScriptConnection)
if connection and connection.Connected then
connection:Disconnect()
end
end
function rt.FindPlayer(val : string) : (Player)
local match
for _, v : Player in pairs(rt.Players:GetChildren()) do
if string.match(v.Name:lower(), val:lower()) or string.match(v.DisplayName:lower(), val:lower()) then
match = v
end
end
return match
end
function rt:Map () : (Model | nil)
for _, v in workspace:GetDescendants() do
if v.Name == "Spawns" and v.Parent.Name ~= "Lobby" then
return v.Parent
end
end
return nil
end
function rt:CheckForConnection () : (boolean) -- if someone reload the script while script this will help us know
if self.player:GetAttribute("Connection") then
return true
end
return false
end
function rt:IsElite() : (boolean)
if self.player:GetAttribute("Elite") then
return true
end
return false
end
function rt:CheckIfGameInProgress () : (boolean)
if rt:Map() then return true end
return false
end
function rt:CheckIfPlayerIsInARound () : (boolean)
--check if player is in a round
--check by going to the players gui -> MainGui -> Game -> Timer.Visible
if not self:MainGUI() then return false end
if self:MainGUI().Game.Timer.Visible then
return true
end
--check by going to the players gui -> MainGui -> Game -> EarnedXP.Visible
if self:MainGUI().Game.EarnedXP.Visible then
return true
end
return false
end
function rt:CheckIfPlayerWasInARound () : (boolean)
--check if player was in a round
--check by going to the players -> localplayer -> GetAttributes() -> "Alive"
if self.player:GetAttribute("Alive") then
return true
end
return false
end
function rt:GetAlivePlayers (): (table | nil)
--get all players that are alive
local aliveplrs = setmetatable({}, {__mode = "v"})
local OldPos = self:Character():GetPivot()
local pos = CFrame.new(-121.995956, 134.462997, 46.4180717)
if not rt:CheckIfGameInProgress() then return nil end
local isAlive = rt:CheckIfPlayerIsInARound()
if not isAlive then self:Character():PivotTo(pos) end
for _, v in pairs(rt.Players:GetPlayers()) do
local distance = (self:Character().PrimaryPart.Position - v.Character.PrimaryPart.Position).Magnitude
if isAlive then
if distance <= 500 then
table.insert(aliveplrs, v)
end
else
if distance > 500 then
table.insert(aliveplrs, v)
end
end
end
if not isAlive then self:Character():PivotTo(OldPos) end
return aliveplrs
end
function rt:GetRoles() : {sheriff: Player | nil, Murderer : Player | nil}
if rt.sheriff ~= nil or rt.Murderer ~= nil then return {sheriff = rt.sheriff, Murderer = rt.Murderer} end
local checkBackPacks = function()
for _, v in pairs(rt.Players:GetPlayers()) do
if v.Backpack:FindFirstChild("Gun") then
rt.sheriff = v
elseif v.Backpack:FindFirstChild("Knife") then
rt.Murderer = v
end
end
end
local checkCharacters = function()
for _, v in pairs(workspace:GetDescendants()) do
if v:IsA("Tool") then
if v.Name == "Gun" then
rt.sheriff = rt.Players:GetPlayerFromCharacter(v.Parent)
elseif v.Name == "Knife" then
rt.Murderer = rt.Players:GetPlayerFromCharacter(v.Parent)
end
end
end
end
coroutine.wrap(checkBackPacks)
coroutine.wrap(checkCharacters)
task.wait(0.5)
return {sheriff = rt.sheriff, Murderer = rt.Murderer}
end
function rt:SpeedUp () : (boolean)
--speed up the player no more than 28
if self:Character():FindFirstChildWhichIsA("Humanoid").WalkSpeed == 28 then return false end
self:Character():FindFirstChildWhichIsA("Humanoid").WalkSpeed += 4
return true
end
function rt:ResetSpeed () : (boolean)
if self:Character():FindFirstChildWhichIsA("Humanoid").WalkSpeed == 16 then return false end
self:Character():FindFirstChildWhichIsA("Humanoid").WalkSpeed = 16
return true
end
function rt:ViewMurderer () : (boolean | string)
if not self.Murderer then self.Viewing = true return false end
if self.Viewing then return Notif:Notify("alr in view", 1, "error") end
self.Viewing = true
self.Camera.CameraSubject = self.Murderer and self.Murderer.Character:FindFirstChildWhichIsA("Humanoid") or self:Character():FindFirstChildWhichIsA("Humanoid")
self.viewChanged = workspace.CurrentCamera:GetPropertyChangedSignal("CameraSubject"):Connect(function()
if not self.Murderer then return rt:UnViewMurderer() end
self.Murderer.CharacterAdded:Wait()
self.Camera.CameraSubject = self.Murderer and self.Murderer.Character:FindFirstChildWhichIsA("Humanoid") or self:Character():FindFirstChildWhichIsA("Humanoid")
end)
self.viewDiedFunc = self.player.CharacterAdded:Connect(function()
rt:UnViewMurderer()
end)
return true
end
function rt:UnViewMurderer () : (boolean | string)
if not self.Murderer then self.Viewing = false; self.Camera.CameraSubject = self:Character():FindFirstChildWhichIsA("Humanoid") return false end
if not self.Viewing then return Notif:Notify("alr removed view", 1, "error") end
self.Viewing = false
local camera = game.Workspace.CurrentCamera
rt.Disconnect(rt.viewChanged)
rt.Disconnect(rt.viewDiedFunc)
self.Camera.CameraSubject = self:Character():FindFirstChildWhichIsA("Humanoid")
return true
end
function rt:GetGun ()
if not (rt:CheckIfGameInProgress()) then return Notif:Notify("No game in progress", 1, "error") end
local Gun = rt:Map():FindFirstChild("GunDrop") :: BasePart | MeshPart -- getinstances()["GunDrop"]
if not Gun then return Notif:Notify("No Gun found", 1, "error") end
if rt.Settings.Safe_Gun_Grab then
local distance = (rt:Character().PrimaryPart.Position - Gun.Position).Magnitude
if distance > 500 then
distance = nil
return Notif:Notify("Gun is too far away [Safe Gun Grab]", 1, "error")
end
end
rt:Character():PivotTo(Gun:GetPivot())
task.wait(0.2) -- wait for the character to pick up the gun
if not rt.player.Backpack:FindFirstChild("Gun") then
return Notif:Notify("Failed to get the gun. Sorry Sheriff you had your chance 😔.", 2, "alert")
end
Notif:Notify("Successfully picked up the gun", 1, "success")
Gun = nil
end
function rt.LoadRoleInfo (roles, MurdFolder : {}, SherFolder : {})
-- Load in Murderer info
if roles.Murderer then
MurdFolder.MurdName:Text("Murderer Username: " .. roles.Murderer.Name)
MurdFolder.MurdKnife:Text("Murderer Knife: " .. (roles.Murderer:GetAttribute("EquippedKnife") or ""))
MurdFolder.MurdKnifeEffect:Text("Murderer Knife Effect: " .. (roles.Murderer:GetAttribute("EquippedEffect") or ""))
MurdFolder.MurdPerk:Text("Murderer Perk: " .. (roles.Murderer:GetAttribute("EquippedPerk") or ""))
MurdFolder.Murdlvl:Text("Murderer Lvl: " .. (roles.Murderer:GetAttribute("Level") or ""))
MurdFolder.MurdPres:Text("Murderer Prestige: " .. (roles.Murderer:GetAttribute("Prestige") or ""))
MurdFolder.MurdXP:Text("Murderer XP: " .. (roles.Murderer:GetAttribute("XP") or ""))
else
MurdFolder.MurdName:Text("Murderer Username: N/A")
MurdFolder.MurdKnife:Text("Murderer Knife: N/A")
MurdFolder.MurdKnifeEffect:Text("Murderer Knife Effect: N/A")
MurdFolder.MurdPerk:Text("Murderer Perk: N/A")
MurdFolder.Murdlvl:Text("Murderer Lvl: N/A")
MurdFolder.MurdPres:Text("Murderer Prestige: N/A")
MurdFolder.MurdXP:Text("Murderer XP: N/A")
end
-- Load in Sheriff info
if roles.sheriff then
SherFolder.SherName:Text("Sheriff Username: " .. roles.sheriff.Name)
SherFolder.SherGun:Text("Sheriff Gun: " .. (roles.sheriff:GetAttribute("EquippedGun") or ""))
SherFolder.Sherlvl:Text("Sheriff Lvl: " .. (roles.sheriff:GetAttribute("Level") or "N/A") or "")
SherFolder.SherPres:Text("Sheriff Prestige: " .. (roles.sheriff:GetAttribute("Prestige") or ""))
SherFolder.SherXP:Text("Sheriff XP: " .. (roles.sheriff:GetAttribute("XP") or ""))
else
SherFolder.SherName:Text("Sheriff Username: N/A")
SherFolder.SherGun:Text("Sheriff Gun: N/A")
SherFolder.Sherlvl:Text("Sheriff Lvl: N/A")
SherFolder.SherPres:Text("Sheriff Prestige: N/A")
SherFolder.SherXP:Text("Sheriff XP: N/A")
end
end
--Checks places where Role Weapons are so it can update who has them
function rt:UpdateRoles()
-- Reset roles
local oldSheriff = rt.sheriff
local oldMurderer = rt.Murderer
rt.sheriff = nil
rt.Murderer = nil
-- Check players' backpacks for tools
for _, player in ipairs(rt.Players:GetPlayers()) do
if player:FindFirstChild("Backpack") then
local backpack = player.Backpack
if backpack:FindFirstChild("Gun") then
rt.sheriff = player
elseif backpack:FindFirstChild("Knife") then
rt.Murderer = player
end
end
end
-- Check workspace for tools attached to characters
for _, descendant in ipairs(workspace:GetDescendants()) do
if descendant:IsA("Tool") then
if descendant.Name == "Gun" then
local owner = rt.Players:GetPlayerFromCharacter(descendant.Parent)
rt.sheriff = owner or rt.sheriff
elseif descendant.Name == "Knife" then
local owner = rt.Players:GetPlayerFromCharacter(descendant.Parent)
rt.Murderer = owner or rt.Murderer
end
elseif descendant.Name == "GunDrop" then
rt.sheriff = nil -- Gun dropped, sheriff is unknown
end
end
-- Refresh UI or ESP if roles have changed
if oldSheriff ~= rt.sheriff or oldMurderer ~= rt.Murderer then
rt.refresh("Roles Updated")
if rt.espON then RefreshRoles(rt.sheriff, rt.Murderer) end
end
end
--This function is a bunch of connectings to triggers
function rt:MonitorTools()
-- Listen for tools being added or removed in players
rt.RoleTracker1 = rt.Players.DescendantAdded:Connect(function(descendant)
if descendant:IsA("Tool") then
if descendant.Name == "Gun" or descendant.Name == "Knife" then
rt:UpdateRoles()
end
end
end)
rt.RoleTracker2 = rt.Players.DescendantRemoving:Connect(function(descendant)
if descendant:IsA("Tool") then
if descendant.Name == "Gun" or descendant.Name == "Knife" then
rt:UpdateRoles()
end
end
end)
-- Listen for tools being added or removed in workspace
rt.WeaponTracker1 = workspace.DescendantAdded:Connect(function(descendant)
if descendant:IsA("Tool") or descendant.Name == "GunDrop" then
rt:UpdateRoles()
end
if descendant:IsA("Model") then
if string.match(descendant.Name, "Glitch") and descendant.Parent.Name ~= "Lobby" then
descendant:Destroy()
end
if string.match(descendant.Name, "Invis") and descendant.Parent.Name ~= "Lobby" then
descendant:Destroy()
end
if string.match(descendant.Name, "Invis") and descendant.Parent.Name ~= "Lobby" then
descendant:Destroy()
end
end
end)
rt.WeaponTracker2 = workspace.DescendantRemoving:Connect(function(descendant)
if descendant:IsA("Tool") or descendant.Name == "GunDrop" then
rt:UpdateRoles()
end
end)
end
------------------------------------INFINITE YEILD SCRIPTS-----------------------------------------------
----------------------------------------------------------------------------------------------------------
local function Fling (targetPlayer)
if rt.flingActive then
rt.flingActive = false
return
end
rt.flingActive = true
local character = rt:Character()
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
local rootPart = humanoid and humanoid.RootPart
local tCharacter = targetPlayer.Character
local tHumanoid = tCharacter and tCharacter:FindFirstChildOfClass("Humanoid")
local tRootPart = tHumanoid and tHumanoid.RootPart
local tHead = tCharacter and tCharacter:FindFirstChild("Head")
local accessory = tCharacter and tCharacter:FindFirstChildOfClass("Accessory")
local handle = accessory and accessory:FindFirstChild("Handle")
if character and humanoid and rootPart then
if rootPart.Velocity.Magnitude < 50 then
getgenv().OldPos = rootPart:GetPivot()
end
if tHumanoid and tHumanoid.Sit then
Notif:Notify("Target is sitting", 5, "error")
return
end
if tHead then
workspace.CurrentCamera.CameraSubject = tHead
elseif handle then
workspace.CurrentCamera.CameraSubject = handle
else
workspace.CurrentCamera.CameraSubject = tHumanoid
end
if not tCharacter:FindFirstChildWhichIsA("BasePart") then
return
end
local function FPos(basePart, pos, ang)
rootPart.CFrame = CFrame.new(basePart.Position) * pos * ang
character:PivotTo(CFrame.new(basePart.Position) * pos * ang)
rootPart.Velocity = Vector3.new(9e7, 9e7 * 10, 9e7)
rootPart.RotVelocity = Vector3.new(9e8, 9e8, 9e8)
end
local function SFBasePart(basePart)
local timeToWait = 2
local time = tick()
local angle = 0
repeat
if rootPart and tHumanoid then
if basePart.Velocity.Magnitude < 50 then
angle = angle + 100
FPos(basePart, CFrame.new(0, 1.5, 0) + tHumanoid.MoveDirection * basePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(angle), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, 0) + tHumanoid.MoveDirection * basePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(angle), 0, 0))
task.wait()
FPos(basePart, CFrame.new(2.25, 1.5, -2.25) + tHumanoid.MoveDirection * basePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(angle), 0, 0))
task.wait()
FPos(basePart, CFrame.new(-2.25, -1.5, 2.25) + tHumanoid.MoveDirection * basePart.Velocity.Magnitude / 1.25, CFrame.Angles(math.rad(angle), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, 1.5, 0) + tHumanoid.MoveDirection, CFrame.Angles(math.rad(angle), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, 0) + tHumanoid.MoveDirection, CFrame.Angles(math.rad(angle), 0, 0))
task.wait()
else
FPos(basePart, CFrame.new(0, 1.5, tHumanoid.WalkSpeed), CFrame.Angles(math.rad(90), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, -tHumanoid.WalkSpeed), CFrame.Angles(0, 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, 1.5, tHumanoid.WalkSpeed), CFrame.Angles(math.rad(90), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, 1.5, tRootPart.Velocity.Magnitude / 1.25), CFrame.Angles(math.rad(90), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, -tRootPart.Velocity.Magnitude / 1.25), CFrame.Angles(0, 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, 1.5, tRootPart.Velocity.Magnitude / 1.25), CFrame.Angles(math.rad(90), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, 0), CFrame.Angles(math.rad(90), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, 0), CFrame.Angles(0, 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, 0), CFrame.Angles(math.rad(-90), 0, 0))
task.wait()
FPos(basePart, CFrame.new(0, -1.5, 0), CFrame.Angles(0, 0, 0))
task.wait()
end
else
break
end
until basePart.Velocity.Magnitude > 500 or basePart.Parent ~= targetPlayer.Character or targetPlayer.Parent ~= rt.Players or not targetPlayer.Character == tCharacter or tHumanoid.Sit or humanoid.Health <= 0 or tick() > time + timeToWait
end
workspace.FallenPartsDestroyHeight = 0 / 0
local bv = Instance.new("BodyVelocity")
bv.Name = "EpixVel"
bv.Parent = rootPart
bv.Velocity = Vector3.new(9e8, 9e8, 9e8)
bv.MaxForce = Vector3.new(1 / 0, 1 / 0, 1 / 0)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
if tRootPart and tHead then
if (tRootPart.CFrame.p - tHead.CFrame.p).Magnitude > 5 then
SFBasePart(tHead)
else
SFBasePart(tRootPart)
end
elseif tRootPart and not tHead then
SFBasePart(tRootPart)
elseif not tRootPart and tHead then
SFBasePart(tHead)
elseif not tRootPart and not tHead and accessory and handle then
SFBasePart(handle)
else
Notif:Notify("Target is missing everything", 5, "error")
return
end
bv:Destroy()
humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)
workspace.CurrentCamera.CameraSubject = humanoid
repeat
rootPart.CFrame = getgenv().OldPos * CFrame.new(0, .5, 0)
character:PivotTo(getgenv().OldPos * CFrame.new(0, .5, 0))
humanoid:ChangeState("GettingUp")
for _, x in ipairs(character:GetChildren()) do