How would i secure this?

  1. What do you want to achieve? Keep it simple and clear!

I want my knife throwing system not be exploitable

  1. What is the issue? Include screenshots / videos if possible!

The issue is that. I dont really know how and if its secure enough

It works as expected. But i don’t want to release a game with a vulnerability obviously
Heres my code atm:

– // Server(Inside tool)

local THROW = game.ReplicatedStorage:FindFirstChild("EVENTS").THROW
local GET = game.ReplicatedStorage:FindFirstChild("FUNCS").GET_MOUSE

local PLAYER = script.Parent.Parent.Parent


script.Parent.Activated:Connect(function() 
	local POS = GET:InvokeClient(PLAYER) -- GET PLAYERS MOUSE POSITION
	if POS then 
		local INFO = {
			["POS_1"] = script.Parent.Handle.Position;
			["MOUSE_POS"] = POS.p
		} -- CREATE TABLE STUFF
		THROW:FireAllClients(INFO) -- FIRE THROW EVENT 
	end
end)

– // Throwing system(Inside starter player scripts)

local EVENT = game.ReplicatedStorage:WaitForChild("EVENTS", true).THROW
local DAMAGE = game.ReplicatedStorage:WaitForChild("EVENTS", true).DAMAGE
local CLONE = game.ReplicatedStorage:WaitForChild("Handle", true)


local CONNECTION = nil

EVENT.OnClientEvent:Connect(function(TABLE)
	local NEW = CLONE:Clone()
	NEW.Position = TABLE["POS_1"] -- POSITION 1 IS THE TOOLS HANDLE
	NEW.CFrame = CFrame.lookAt(NEW.Position, TABLE["MOUSE_POS"]) 
	NEW.Velocity = NEW.CFrame.lookVector * 100 + Vector3.new(0, 40, 0)
	NEW.Parent = game.Workspace
	
	CONNECTION = NEW.Touched:Connect(function(HIT)
		if HIT.Parent:FindFirstChild("Humanoid") then
			DAMAGE:FireServer(HIT.Parent.Humanoid) -- IF WE TOUCHED A HUMANOID. TELL THE SERVER TO DAMAGE IT
		end
	end)
end)

– // Mouse function(Inside starter player scripts also)

local FUNC = game.ReplicatedStorage:WaitForChild("FUNCS", true).GET_MOUSE

local PLAYER = game.Players.LocalPlayer
local MOUSE = PLAYER:GetMouse()


FUNC.OnClientInvoke = function()
	return MOUSE.Hit -- RETURN PLAYERS MOUSE
end

Any help is higly appreciated as always :smiley:!!

Nothing is completely secure from exploiters, however you can mitigate or stop their attacks by just ensuring that all values are as they should be on the server. Handle anything which you think the server can handle that requires security on the server. Be mindful of what you do on the server though.

1 Like

Trying to detect if there’s more knifes than possible at once.

1 Like

Alright. I’ll try that. But i have 1 question left?

How would i stop(If possiblee) exploiters from exploiting the damage event

Check if the knife (hitbox) touches another player.

1 Like

Event.OnServerEvent:Connect(function(Player, Hit) -- Do the rest here. end)

1 Like