Hello DevForum Community
I have a problem out of the blue my gun scripts dosent register player torso shots ?.
Ive tested around because i thouhg it was my gunback script wich creates a model around torso but i fixed that issue. I found out it was the HumanoidRootPart.
Here is a Video about my problem. Once i deleted humanoidRootPart the torso shots were registered.
All it does (i have a wallbang function) the shot goes through the player because the hit object is being scanned if his parent has a humanoid if yes then make the shot go through wich does it fine. However for some reason it dosent fire the event to the serversided script wich deals the damage to the player ?
Here is the portion of the script
elseif Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Humanoid.Health == 0 or Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent:FindFirstChild("Humanoid") and PiercedHumanoid[Hit.Parent.Humanoid] then
if EndPos and Hit then
Player.PlayerScripts.BulletVisualizerScript.Visualize:Fire(nil,ShootingHandle, Module.MuzzleOffset,EndPos,script.MuzzleEffect, script.HitEffects.Blood, Module.Blood_HitSound, {Module.ExplosiveEnabled,Module.BlastRadius,Module.BlastPressure},{Module.BulletSpeed,Module.BulletSize,Module.BulletColor,Module.BulletTransparency,Module.BulletMaterial,Module.FadeTime},false,PierceAvailable == -1 and Module.VisualizerEnabled or false, Hit, BulletRay)
game.ReplicatedStorage.VisualizeBullet:FireServer(ShootingHandle, Module.MuzzleOffset,EndPos,script.MuzzleEffect, script.HitEffects.Blood, Module.Blood_HitSound, {Module.ExplosiveEnabled,Module.BlastRadius,Module.BlastPressure},{Module.BulletSpeed,Module.BulletSize,Module.BulletColor,Module.BulletTransparency,Module.BulletMaterial,Module.FadeTime},true,PierceAvailable == -1 and Module.VisualizerEnabled or false, Hit, BulletRay)
local decal = Instance.new("Decal")
local decal2 = Instance.new("Decal")
local decal3 = Instance.new("Decal")
local decal4 = Instance.new("Decal")
decal.Texture = "rbxassetid://246162648"
decal.Face = "Front"
decal.Parent = Hit
decal2.Texture = "rbxassetid://246162648"
decal2.Face = "Back"
decal2.Parent = Hit
decal3.Face = "Left"
decal3.Texture = "rbxassetid://246162648"
decal3.Parent = Hit
decal4.Parent = Hit
decal4.Texture = "rbxassetid://246162648"
decal4.Face = "Right"
end --[[The Section above makes the bullet go through if Hit.Parent finds humanoid wich it does because the HumanoidRootPart is modelled togheter with the player]]--
local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
local TargetTorso = Hit.Parent:FindFirstChild("Torso")
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
InflictTarget:FireServer(TargetHumanoid, TargetTorso, (Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage, Direction, Module.Knockback, Module.Lifesteal, Module.FlamingBullet, Hit)
PiercedHumanoid[TargetHumanoid] = true
end
if AcceptedUnit == BulletUnit then
Hit, EndPos = RayCast(EndPos+(BulletUnit*.01),BulletUnit,Range-((Start-EndPos).magnitude),Ignore)
elseif AcceptedUnit == MouseUnit then
Hit, EndPos = RayCast(EndPos+(Direction*.01),Direction,Range-((Start-EndPos).magnitude),Ignore)
end
end
end```
EDIT: I also put a print in InflictTarget. When shooting HumanoidRootPart the event dosent get fired because the print dosent appear. But once i tested and i didnt move the player after he spawned the shot got registerd on torso so i belive it ether hit his arm or it sometimes hits the torso ???