Best way to achieve exploit proof projectiles?

I’m trying to achieve secure and as smooth as possible projectiles that can’t be manipulated by exploiters.

Currently I’m lerping the CFrame manually on the server and using raycasts to check for collisions, here’s some pseudocode to help understand what I’m doing:

local knife_lifetime = 5
local knife_last_position = knife.Position
local start_time = tick()
while wait() do
	local current_time = tick() - start_time
	local percent_finished = current_time / knife_lifetime
	if percent_finished > 1 then
		percent_finished = 1
	end
	
	-- Move knife
	knife.CFrame = knife_start_position:Lerp(knife_end_position, percent_finished)
	
	-- Hitbox check
	local ray_direction = knife.Position - knife_last_position
	local ray_result = workspace:Raycast(knife_last_position, ray_direction, raycast_params)
	if ray_result then
		--- Handle knife hitting something...
	end
	
	knife_last_position = knife.Position

	if percent_finished >= 1 then
		break
	end
end

Is this the best way to achieve what I need?
I do know that it’s better to handle only the CFrames on the server and make the client replicate the knives, but that’s something I’ll do later on.

1 Like