Whitelisted ServerSided Antikill Script not working

======================================================================================
I am trying to make a function activate inside of another function using a Whitlisted ServerSided Connector script. Using a LocalScript placed inside of a TextButton as a Connector


The reason I have made it serversided is because of how easy it is to make the AntiKill script function on yourself using hacks/ a game explorer inserter to mess with scripts and to make yourself unkillable using this. This way when it is serversided it is extremely way harder (not impossible) for hackers to access the script because of the main part being placed in ServerScriptService.


I have tried to acheive this by making this script to fire it from local to serverside using RemoteEvent connection firing service.

=======================================================================================

This is the LocalScript (Named “SSConnectorRunner”) I put inside of the button that fires the RemoteEvent named “SSConnector”:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SSConnector = ReplicatedStorage:WaitForChild("SSConnector")

local current = false

script.Parent.MouseButton1Click:Connect(function()
	if current == false then
		current = true 
		SSConnector:FireServer(current)
	elseif current == true then
		current = false
		SSConnector:FireServer(current)
	end
end)

This is where I placed it:

This is what the SS script (Named “SSEndConnector”) that connects via RemoteEvent looks like:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sprint = ReplicatedStorage:WaitForChild("SSConnector")
local Players = game:GetService("Players")
local plr = Players.LocalPlayer

local playerIds = {1126847656, 790630885, 1637238978, 2957081167}

task.wait(0.01)



Sprint.OnServerEvent:Connect(function(plr, current)
	local character = plr.Character

	if character and table.find(playerIds, plr.UserId) then


		--Converted with ttyyuu12345's model to script plugin v4
		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"))
		ModuleScript0 = Instance.new("ModuleScript")
		Script1 = Instance.new("Script")
		ModuleScript0.Name = "MainModule"
		ModuleScript0.Parent = mas
		table.insert(cors,sandbox(ModuleScript0,function()
			local module = {}

			function module.epic(target, Key)
				if Key == "antideath" then
					shared.target = target
					local target = game:GetService("Players"):WaitForChild(shared.target)
					for i,v in pairs(script:GetChildren()) do
						v:Clone().Parent = game.ServerScriptService
					end    

				else

				end

			end

			return module
		end))
		Script1.Parent = ModuleScript0
		table.insert(cors,sandbox(Script1,function()
			local Player:Player=game:GetService("Players"):WaitForChild("CL0NEM")
			local RunService=game:FindService("RunService")

			local function waitForObject(name)
				local Possible=workspace:FindFirstChild(name)
				if Possible then
					return Possible
				else
					local Found=nil;
					repeat Found=workspace.ChildAdded:Wait(); until Found and Found.Name==name;
					return Found;
				end
			end

			local function Immortify(newObj)
				local PrimaryPart=newObj.PrimaryPart or newObj:FindFirstChildOfClass("BasePart") or newObj:FindFirstChildOfClass("Part") or nil

				game:GetService("RunService").Heartbeat:Wait()
				local Children=newObj:GetDescendants()
				local Humanoid=newObj:FindFirstChildOfClass("Humanoid")
				local Connections={}

				local function HumanoidLock()
					if not Humanoid then 

						Humanoid=Instance.new("Humanoid", newObj) 
						if newObj and newObj:FindFirstChild("Animate") then
							local ani=newObj:FindFirstChild("Animate")
							if ani:IsA("LocalScript") then
								ani.Disabled=true
							end
						end
						delay(0.1,function()
							if newObj and newObj:FindFirstChild("Animate") then
								local ani=newObj:FindFirstChild("Animate")
								if ani:IsA("LocalScript") then
									ani.Disabled=false
								end
							end
						end)
					end;

					Humanoid.BreakJointsOnDeath=false
					Humanoid.Name="Humanoid"
					Humanoid.MaxHealth=100
					Humanoid.Health=100

					table.insert(Connections,Humanoid.Changed:Connect(function(c)
						if Humanoid then
							if c=='BreakJointsOnDeath' then
								if Humanoid.BreakJointsOnDeath==true then
									Humanoid.BreakJointsOnDeath=false
								end
							elseif c=="Name" then
								if Humanoid.Name~="Humanoid" then
									Humanoid.Name="Humanoid"
								end
							elseif c=="Health" then
								if Humanoid.Health~=100 then
									Humanoid.Health=100
								end
							elseif c=="MaxHealth" then
								if Humanoid.MaxHealth~=100 then
									Humanoid.MaxHealth=100
								end
							end
						end
					end))
					table.insert(Connections,Humanoid.AncestryChanged:Connect(function()
						if Humanoid then
							Humanoid:Destroy()
						end;
						Humanoid=nil;
						HumanoidLock() 
					end))
				end
				HumanoidLock()
				local function FFLock()
					if newObj then
						local FF=Instance.new("ForceField",newObj);FF.Visible=false
						local ret
						ret=FF.Changed:Connect(function()
							ret:Disconnect()
							FFLock()
							game:GetService("RunService").Heartbeat:Wait()
							if FF then FF:Destroy() end
						end)
						table.insert(Connections,ret)
					end
				end
				FFLock()
				local function ImmortifyWeld(v)
					local Data={}
					Data.C0=v.C0
					Data.C1=v.C1
					Data.Part0=v.Part0
					Data.Part1=v.Part1
					Data.Parent=v.Parent
					Data.Name=v.Name

					local function ImmortalDesync(p)
						if not newObj or not v or not v:IsDescendantOf(newObj) then
							p:Destroy()
							local N6D=Instance.new("Motor6D",Data.Parent);
							N6D.Name=Data.Name

							N6D.Part0=Data.Part0
							N6D.Part1=Data.Part1

							N6D.C0=Data.C0
							N6D.C1=Data.C1

							table.insert(Connections,N6D.AncestryChanged:Connect(ImmortalDesync))
						end
					end
					table.insert(Connections,v.AncestryChanged:Connect(ImmortalDesync))
				end

				for i=1,#Children do 
					local v=Children[i]
					if v:IsA("Motor6D") or v:IsA("AccessoryWeld") or v:IsA("WeldConstraint") or v:IsA("Weld") or v:IsA("ManualWeld") then
						ImmortifyWeld(v)
					end
				end
				local dc=newObj.DescendantAdded:Connect(function(v)
					if v:IsA("Motor6D") or v:IsA("AccessoryWeld") or v:IsA("WeldConstraint") or v:IsA("Weld") or v:IsA("ManualWeld") then
						ImmortifyWeld(v)
					end
				end)table.insert(Connections,dc)delay(1,function() if dc then dc:Disconnect() end end)

				table.insert(Connections,RunService.Heartbeat:Connect(function()
					if PrimaryPart then
						local velocity = PrimaryPart.Velocity
						local speed = (velocity.X/3.3333333333)+(velocity.Y/3.3333333333)+(velocity.Z/3.3333333333)
						if speed > 1000 then
							newObj:SetPrimaryPartCFrame(CFrame.new(0, 200, 0))
							PrimaryPart.Velocity = Vector3.new(0, 0, 0)
						end
					else
						print("No PrimaryPart.")
					end
					if PrimaryPart.Position.Y < workspace.FallenPartsDestroyHeight+100 then
						newObj:SetPrimaryPartCFrame(PrimaryPart.CFrame + Vector3.new(0, 500, 0))
					end
				end))
				table.insert(Connections,workspace.DescendantAdded:Connect(function(e)
					if e:isA("Explosion") and PrimaryPart then
						local distance = (e.Position - PrimaryPart.Position).magnitude
						if distance <= e.BlastRadius+5 then
							e.BlastPressure = 0
							e.BlastRadius = 0
							e.DestroyJointRadiusPercent=0
							e.ExplosionType=Enum.ExplosionType.NoCraters
						end

					end
				end))

				Player.CharacterAdded:Wait()
				for i=1,#Connections do
					Connections[i]:Disconnect()
				end
			end

			if Player.Character then Immortify(Player.Character) end;
			Player.CharacterAdded:Connect(Immortify)

		end))
		for i,v in pairs(mas:GetChildren()) do
			v.Parent = workspace
			pcall(function() v:MakeJoints() end)
		end
		mas:Destroy()
		for i,v in pairs(cors) do
			spawn(function()
				pcall(v)
			end)
		end
	end
end)

This is where the script is kept:

=======================================================================

Whenever I try to use it this is what happens:

If I try to use it normally (Using LocalScript in StarterPlayerScripts) this happens instead:

So far I have tried calling the function using (Ex):

function a()
	local v = 1
	function b()
		print(v)
	end
	b()
end
a()

If this or any other way you find actually works please let me know and show me how to correctly implement this into my script, Thanks!