forked from idioticanisgae-pixel/RandomScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAntiKick.lua
More file actions
129 lines (106 loc) · 3.36 KB
/
Copy pathAntiKick.lua
File metadata and controls
129 lines (106 loc) · 3.36 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
local players: Players = game:GetService("Players")
local guiService: GuiService = game:GetService("GuiService")
local teleportService: TeleportService = game:GetService("TeleportService")
local coreGui: CoreGui = game:GetService("CoreGui")
local runService: RunService = game:GetService("RunService")
local logService: LogService = game:GetService("LogService")
local localPlayer: Player = players.LocalPlayer
local placeId: number = game.PlaceId
local jobId: string = game.JobId
local rawMetatable: any = getrawmetatable(game)
local oldNamecall = rawMetatable.__namecall
local oldIndex = rawMetatable.__index
local oldNewIndex = rawMetatable.__newindex
setreadonly(rawMetatable, false)
local function bypassInternal(self, ...): any
local method: string = getnamecallmethod()
local args: any = { ... }
if not checkcaller() then
if (method == "Kick" or method == "kick") and self == localPlayer then
return task.wait(9e9)
end
if method == "BreakJoints" and self == localPlayer.Character then
return nil
end
if method == "SetCore" and args[1] == "PromptSignIn" then
return nil
end
end
return oldNamecall(self, ...)
end
rawMetatable.__namecall = newcclosure(bypassInternal)
rawMetatable.__index = newcclosure(function(self, key: any): any
if not checkcaller() then
if (key == "Kick" or key == "kick") and self == localPlayer then
return newcclosure(function()
return task.wait(9e9)
end)
end
if key == "Clonable" and self:IsA("LocalScript") then
return true
end
end
return oldIndex(self, key)
end)
setreadonly(rawMetatable, true)
local function secureEnvironment(): ()
for _, value in ipairs(getgc(true)) do
if typeof(value) == "function" and islclosure(value) and not isexecutorclosure(value) then
local constants: any = debug.getconstants(value)
local info = debug.getinfo(value)
for _, constant in ipairs(constants) do
if typeof(constant) == "string" then
local lowerConstant: string = constant:lower()
if lowerConstant == "kick" or lowerConstant == "ban" or lowerConstant == "crash" then
hookfunction(value, function(...)
return nil
end)
break
end
end
end
end
end
end
local function handleBypassGui(descendant: Instance): ()
if descendant:IsA("TextLabel") then
local text: string = descendant.Text:lower()
if
string.find(text, "kick")
or string.find(text, "ban")
or string.find(text, "disconnected")
or string.find(text, "error")
then
descendant.Text = "Security: Attempted Disconnection Intercepted"
end
end
end
local function performRejoin(): ()
if #players:GetPlayers() <= 1 then
teleportService:Teleport(placeId, localPlayer)
else
teleportService:TeleportToPlaceInstance(placeId, jobId, localPlayer)
end
end
guiService.ErrorMessageChanged:Connect(function()
task.wait(0.2)
performRejoin()
end)
teleportService.TeleportInitFailed:Connect(function()
task.wait(1)
performRejoin()
end)
logService.MessageOut:Connect(function(message: string, messageType: MessageType)
if messageType == Enum.MessageType.MessageError then
if string.find(message:lower(), "kick") or string.find(message:lower(), "sent disconnect") then
task.spawn(performRejoin)
end
end
end)
pcall(function()
for _, descendant in ipairs(coreGui:GetDescendants()) do
handleBypassGui(descendant)
end
coreGui.DescendantAdded:Connect(handleBypassGui)
end)
task.spawn(secureEnvironment)