Im posting this again because I haven’t found a solution. Basically I can headshot npcs but not players. Although body shots work on players. Anyone know why or have an idea?
function Fired(player, mouse, startpoint)
local character = player.Character or player.CharacterAdded:Wait()
local HRP = character:WaitForChild("HumanoidRootPart")
local Tool = character:FindFirstChildOfClass("Tool")
if Tool:FindFirstChild("BulletCount") then
if Tool:FindFirstChild("BulletCount").Value==0 or Tool:FindFirstChild("BulletCount").Value<0 then return end
Tool:FindFirstChild("BulletCount").Value-=1
local Config = Tool:FindFirstChild("Config")
if not Config then return end
VFX:FireAllClients( "BulletSound", character, Config.ShootSFX.Value)
VFX:FireAllClients("SmallShine", startpoint)
local Params = RaycastParams.new()
local BlockedAccessories = {}
for _, v in pairs(workspace:GetDescendants()) do
if v:IsA("Accessory") then
table.insert(BlockedAccessories, v)
end
end
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = character:GetDescendants()
Params:AddToFilter(BlockedAccessories)
local Direction = (mouse.Position - startpoint).Unit * range
local Raycast = workspace:Raycast(startpoint, Direction, Params)
if Raycast then
local hit = Raycast.Instance
local EndPos = Raycast.Position
VFX:FireAllClients("BulletParticle", startpoint, Config.BulletColor, EndPos,true)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name~=player.Name then
local Hum = hit.Parent:FindFirstChild("Humanoid")
if Hum.Health<1 then return end
print(hit.Name)
if hit.Name=="Head" then
local Check = DMGMOD.DamageEnemy(player, hit.Parent, Hum, 100)
local KillEffect = Config:FindFirstChild("KillEffect")
CheckKFX(Check, KillEffect.Value, hit.Parent, true, player)
return
elseif hit.Name~="Head" then
local Check = DMGMOD.DamageEnemy(player, hit.Parent, Hum, 25)
local KillEffect = Config:FindFirstChild("KillEffect")
CheckKFX(Check, KillEffect.Value, hit.Parent, false, player)
return
end
end
elseif not Raycast then
VFX:FireAllClients("BulletParticle", startpoint, Config.BulletColor, Direction, false)
print("Not Hit")
end
end
end