So I've been looking for ways to secure my game and make my own little anti-cheat. When I realized I couldn't do a lot on the server with the humanoid because its network ownership was the client (at least I think so, nothing worked for me). I figured why not make the anti-exploit stuff in a local script but have the server check for the local script and if it's not disabled.

The server script is in StarterCharacterScripts

ServerScript:

local char = script.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local message = "Your client's behavior was suspicious"

local ClientSide = script:WaitForChild("YourLocalScript"):Clone()
local waitTime = 60 -- Whatever time

function ReSecure()
	local ClientSideRep = ClientSide:Clone()
	local ClientSideOld = script:FindFirstChild("YourLocalScript")
		if ClientSideOld then
			ClientSideOld:Remove()
	else
			plr:Kick(message)
		end
	ClientSideRep.Parent = script
end
-- Possibly add a check for if the script is disabled (but it's unnecessary)

while wait(waitTime) do
	ReSecure()
end

So my question is: Is there anything wrong with this method? I've tested it in studio dozens of times and I can't think of any ways they'd be able to bypass it unless they have direct access to the server script.

7 comments

0

Another way I found is if they somehow load faster than the server script and delete it before it can be cloned, but I feel like that's next to impossible and the effort of finding another way might not be worth the chance

0

u could put the script in serverscript then access the player in game.Players (Only a suggestion)

0

@Beart--- Client CAN NOT access ServerScriptService, so you won't need to worry about it

0

That's a good suggestion. I'm contemplating just moving the local script to ServerStorage. I have the server script in the character so it restarts everytime the character dies

0

@Nguyenlegiahung The scripts were in StarterCharacterScripts but now I have the local script get cloned from ServerStorage into the serverscript

0

@Bear Local script can not run in ServerScript

0

@Nguyen I know, I said that it gets cloned into the serverscript not serverscriptservice the local script runs fine in the serverscript which is in the character