Problem with hit detection with bombs

Hello, I am making a bomb drop system but I have a problem, bombs are exploding in the middle of the air:

image

However, this only happens when I test it in-game. When I test it in studio it works perfectly:

image

This is the script I am using:

local function bombStuff()
			local newBomb = workspace.Bombs.Bomb:Clone()
			
			newBomb.Parent = workspace.BomsTorpedosMisilesOnGoing
			newBomb.Anchored = false
			newBomb.CFrame = CFrame.lookAt(script.Parent.Parent.MeshPart.Position, mouseHit)
		
			local touchEvent
			
			touchEvent = newBomb.Touched:Connect(function(otherThing)
				if seatedCharacter and seatedPlayer then
					if not otherThing:IsDescendantOf(script.Parent.Parent) and not otherThing:IsDescendantOf(seatedCharacter) and not otherThing:IsDescendantOf(workspace.FirePartsAndOtherStuff) and not otherThing:IsDescendantOf(workspace.BomsTorpedosMisilesOnGoing) then
						newBomb.Anchored = true
						newBomb.Transparency = 1
						newBomb.Size = Vector3.new(0.01, 0.01, 0.01)
						newBomb.CFrame = CFrame.new(newBomb.Position.X, newBomb.Position.Y - 0.38, newBomb.Position.Z)
						newBomb.Parent = workspace.FirePartsAndOtherStuff
						
						local newExp = Instance.new("Explosion", newBomb)

						newExp.Position = newBomb.Position
						newExp.ExplosionType = Enum.ExplosionType.NoCraters
						newExp.BlastRadius = 20
						newExp.BlastPressure = 1
						newExp.DestroyJointRadiusPercent = 0
						
						local newFire = Instance.new("Fire", newBomb)

						newFire.Heat = 1
						newFire.Color = Color3.fromRGB(95, 54, 28)
						newFire.SecondaryColor = Color3.fromRGB(0, 0, 0)
						newFire.Size = 20

						local newSmoke = Instance.new("Smoke", newBomb)

						newSmoke.Color = Color3.fromRGB(26, 26, 26)
						newSmoke.Opacity = 0.5
						newSmoke.RiseVelocity = 5
						newSmoke.Size = 3.6
						
						local newExpSound = seat.ExplosionSound:Clone()

						newExpSound.Parent = newBomb
						newExpSound:Play()
						
						game:GetService("Debris"):AddItem(newExpSound, newExpSound.TimeLength)--]]
						game:GetService("Debris"):AddItem(newBomb, 1000)
						
						newExp.Hit:Connect(function(otherPart, distance)
							if otherPart.Parent:FindFirstChild("Humanoid") then
								if game.Players:GetPlayerFromCharacter(otherPart.Parent) then
									local otherPlayer = game.Players:GetPlayerFromCharacter(otherPart.Parent)
									
									if otherPlayer.Team ~= seatedPlayer.Team then
										otherThing.Parent.Humanoid:TakeDamage(90)
									end
								else
									otherPart.Parent.Humanoid:TakeDamage(90)
								end
							end
						end)
						if touchEvent then touchEvent:Disconnect() end
					end
				end
			end)
		end
		spawn(bombStuff)

Thanks!

1 Like

Try setting the bomb’s network ownership to the server
BasePart:SetNetworkOwner (roblox.com)
This should fix your problem.

local function bombStuff()
			local newBomb = workspace.Bombs.Bomb:Clone()
			newBomb.Parent = workspace.BomsTorpedosMisilesOnGoing
			newBomb.Anchored = false
			newBomb.CFrame = CFrame.lookAt(script.Parent.Parent.MeshPart.Position, mouseHit)
			newBomb:SetNetworkOwner()
1 Like