How to protect this tool from being exploited?

Last days my game getting exploited a lot, and the reason of it is spam tool from exploit named “Acrylix”, that taking every models of aim attacks and using it, it causing a lot of lags and killing everyone, how do i patch that in these tools so they dont do that again?

example of tool scripts:
Server Script:

local Event = script:WaitForChild("FrameEvent")
local model = game.ReplicatedStorage["Attack"] -- the name of the model here

Event.OnServerEvent:connect(function(player, mouseX, mouseY, mouseZ)
	local the = model:Clone()
	the.Parent = game.Workspace
	the:SetPrimaryPartCFrame(CFrame.new(mouseX, mouseY+1, mouseZ))
	the:WaitForChild("Creator").Value = player.Character
end)

Client Script:

local tool = script.Parent
local player = game.Players.LocalPlayer

local Cooldown = 5

script.Parent.Name = "Attack"

enabled = true
task.wait(0.01)
local Event = script.Parent.Script:WaitForChild("FrameEvent")

tool.Equipped:connect(function(mouse)
	mouse.Button1Down:connect(function()
		if enabled == true then
			enabled = false
			script.Parent.Name = 'Cooldown'
			Event:FireServer(mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z)
			if script.Parent.Parent.Name ~= "Baby_Stando" then
				task.wait(Cooldown)
				script.Parent.Name = 'Attack'
				enabled = true
		    end
		end
	end)
end)

I tried Many ways like putting model of the attack not in replicated storage, made script that changes tool name every 1 second, made script that kick you if you use Spam Tool but still nothing work its just bypassing this. Would really appreciate if someone will help me.

The cooldown should be handled the server to prevent hackers from simply setting the cooldown to 0. I also recommend simply running this entire script on the server, by sending a remote event after mouse.Button1Down.

On top of that, cast a ray from the character to the set cursor position and ensure no blockades are there. You might also want to perform a distance check/restriction as your attack currently seems to be capable of being made at any distance. On another note, send Mouse.Hit.Position over each individual axis. You can read them on the server. Finally, you have a memory leak. Remove Mouse.Button1Down and Tool.Equipped, and exchange it for the single Tool.Activated event. Your attacks also seem to have no end, as the model is never destroyed. You should add a lifespan or limit

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.