Barrel collision doesn't work properly

When testing my Donkey Kong game, I came to the conclusion that the hit box of fast moving barrels came earlier than the barrels as you can see in the video:

In the code for the barrel hit detection I make use of ClientCast:ClientCast - A Client-based, Idiosyncratic Hitbox System!

local clientCast = require(game.ServerStorage.ClientCast)
for j =-2.099,2.143,1 do
	local attachment ="Attachment",script.Parent.Union)
for i = -2.099,2.143,.1   do
		local attachment ="Attachment",script.Parent.Union)
		attachment.Name = "DmgPoint"
		attachment.Position =,j,0)

local caster =,

local db = {}

	if db[hithumanoid] then return end
	db[hithumanoid] = true
	db[hithumanoid] = false


I have no clue how to fix this…
I’ve got a ping of 70ms
Any Ideas?

1 Like

If you could can you show ur script that detects when it get hit?

1 Like

It’s very difficult to understand everything that is happening in this scene.

Are you using the .Touched event for getting hit?
What does your ping look like (ctrl+alt+F7)?

If you are using .Touched then it looks like your barrels are simply lagging which may be because of how many physics objects and server scripts there are. Using SetNetworkOwner on the barrels might help in that case. It’s hard to say without much more information.

1 Like

Setting the barrel’s ownership to the client is a major security risk.


When you said fast, I’ll assume you used touched, use region3 instead.

1 Like

Please explain further. My assumption is at worst a hacker could move the barrel anywhere.

1 Like

hey, two things you could try:

  1. use Caster:StartDebug() to see whats up with the rays.
  2. Use Caster:SetOwner(Player) to see if this would fix it, as I believe replication lag could be at play here.

I tried :SetOwner(Player) and it indeed reduced the delay. Maybe the rest of the delay comes from my ping then?

Yeah, that seems to be the case. Since the client handles network replication of it’s own character, you may see yourself jumping instantly, but the replication would be delayed by 100-200ms on the server.


The network ownership being set to the client means the client can change the barrel’s position or add velocity/remove velocity whereas on the server it can’t do anything unless the network owner is set to nil.