game.ReplicatedStorage.FireEvent.OnServerEvent:Connect(function(plr,pos,origPos,dmg)
print('d')
local e = RaycastParams.new()
e.FilterDescendantsInstances = {plr.Character}
e.FilterType = Enum.RaycastFilterType.Blacklist
e.IgnoreWater = false
local rayDirection = origPos - pos
local raycastResult = workspace:Raycast(origPos, rayDirection, e)
if raycastResult then
print('e')
local hitPart = raycastResult.Instance
local hitParent = hitPart:FindFirstAncestorOfClass('Model')
local hum = hitParent:FindFirstChild('Humanoid')
hum.Health = hum.Health - dmg
end
end)
You did not give it a value on how long it will go.
It is probably because you are aiming at the sky and not aiming at a part which would not get a result or the part is too far.
You should output some variables - like making sure your direction is correct. You’re going in blind without double checking your data.
However, there is also the possibility the direction vector isn’t long enough. The point the mouse hits may be on the surface and not actually intersecting the part. Add a few more studs to the distance in that direction.
origin - pos
Is the direction + magnitude to the location but it may not be long enough to actually intersect.
local hitParent = hitPart:FindFirstAncestorOfClass('Model')
print('f')
print(hitParent.Name)
local hum = hitParent:FindFirstChild('Humanoid')
if hum then
local dmgUI = game.ReplicatedStorage.DMG_UI:Clone()
dmgUI.Parent = hitParent:FindFirstChild('Head')
dmgUI.dmg.Text = '<b>-'..dmg..'</b>'
hum.Health = hum.Health - dmg
end
end