.Touched not accurate at all

Ok so I’ve been having this godawful issue in my game for the past couple of days, and I still have no Idea how to fix it. Basically, what my script is, is that when the cannonball is touched, spawn an explosion at the position at the cannonball. For some reason, it’s getting the position of where the cannonball was like a quarter of a second ago. If you want my code, here:

			c.Touched:Connect(function(Hit)
				
				if Hit.Parent:IsA("Accessory") then return end
				if Hit.Parent:FindFirstChild("Humanoid") then return end
				if Hit.Parent.Parent:FindFirstChild("Humanoid") then return end
				
				if not Hit:IsDescendantOf(SpecifiedUnit.Parent) and TouchDebounce == false then
					
					TouchDebounce = true
					
					local Explosion = Instance.new("Explosion")
					Explosion.ExplosionType = Enum.ExplosionType.NoCraters
					Explosion.Position = c.Position
					Explosion.Parent = game.Workspace
					Explosion.BlastRadius = 5
					Explosion.DestroyJointRadiusPercent = 0
					Explosion.BlastPressure = 0
					
					local SoundPart = Instance.new("Part")
					SoundPart.CanCollide = false
					SoundPart.Parent = game.Workspace
					SoundPart.Anchored = true
					SoundPart.Transparency = 1
					SoundPart.Name = "Sound"
					SoundPart.Size = Vector3.new(.05,.05,.05)
					SoundPart.Position = c.Position
					
					local Sound = game.ReplicatedStorage.Sounds.Explosion:Clone()
					Sound.Parent = SoundPart
					Sound:Play()
					
					Debris:AddItem(SoundPart,5)
					
					Explosion.Hit:Connect(function(Object)
						if Object.Parent then
							if Object.Parent:FindFirstChild("Humanoid") then
								Object.Parent.Humanoid.Health = 1
								CalculateDamage(SpecifiedUnit,Object.Parent)
							end
						end
					end)
				end
			end)

Does anyone know why this is happening?

1 Like

Is the cannon ball network ownershipped to the player?
And is the touched event on the server?

2 Likes

Seems like the touched event is firing quite early, this is caused due to a replication issue. I also made a similar topic about the .Touched event, in which you can find solutions I used in the forum topic I created:

The following solution that worked for me was this post in the forum:

Why not do a .Hit event for the Explosion instance and deal damage based on how far away the character hit was from the explosion?