local function OnExplosionHit(hitPart, hitDistance, blastCenter) local character, humanoid = FindCharacterAncestor(hitPart.Parent) print(hitPart.Name) if hitPart.Name == "CenterPart" then return false end if humanoid and humanoid.Health > 0 then if hitPart.Name == 'HumanoidRootPart' then humanoid:TakeDamage(100) end elseif hitPart.Parent:FindFirstChild("CannonballHit") ~= nil then print("Found Function") print(tonumber(hitPart.Name)) if tonumber(hitPart.Name) ~= nil then if hitPart.Parent.CannonballHit:Invoke( tonumber(hitPart.Name), script:FindFirstChild('Damage').Value ) then hitPart:BreakJoints() local blastForce = Instance.new('BodyForce', hitPart) blastForce.force = (hitPart.Position - blastCenter).unit * script:FindFirstChild('BlastForce').Value * hitPart:GetMass() game.Debris:AddItem(blastForce, 0.1) end end end end cannonball.Touched:connect(function(other) local explosion = Instance.new("Explosion") explosion.BlastPressure = 0 explosion.ExplosionType = Enum.ExplosionType.NoCraters explosion.BlastRadius = 1 explosion.Position = cannonball.Position explosion.Parent = cannonball local connection = explosion.Hit:connect(function(hitPart, hitDistance) print(hitPart.Name) OnExplosionHit(hitPart, hitDistance, explosion.Position) end) wait(.1) cannonball:Destroy() end)
When the cannonball hits a part, even one I deliberately renamed to test it out. It always prints the name "Part" and the parent is always "workspace" even if the part is in a model. I have no idea why it is doing this? If anyone can point out what I'm doing wrong I would appreciate it.