Hit detection offsets while using linear velocity?

The hit detection of the moving cube is pushed a bit ahead of where its moving. I’d like it so it would detect parts that are visually touching it.

Script below is a child of the pink moving cube

while true do
	
	local touchList = workspace:GetPartBoundsInBox(script.Parent.CFrame, script.Parent.Size)
	
	for i, touchedPart in pairs(touchList) do
		
		local player = Players:GetPlayerFromCharacter(touchedPart.Parent)
		
		if not player then -- if it doesnt hit a player
			continue -- end
		end
		
		if LocalGetter:Get(player, 'attributes', 'Deflect') then -- if the player is deflecting 
			-- LocalGetter is a custom module i made to get client sided objects/values
			continue -- end
		end
		
		print('we hit a Player!!!!')
	end
	
	task.wait()
end

Thanks in advanced.

You can use a simple Magnitude check, basically it checks the distance between every player and the cube in a 3 stud radius repeatedly. And u could Bind it so you could Unbind it whenever you don’t need it to check the player touching/near the cube :))

1 Like

While this does work, it’s highly inaccurate.

Thanks for helping me out tho

The problem is that you’re doing it on the server. I’ve got a guide that covers how to make client-sided hitboxes, as well as containing other information as well.

1 Like

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