So I was using the FastCast module when I encountered a bug during testing. It wouldn’t damage the player, at first I thought it was the module it’s self but it actually was because of the UGC my friend was wearing. Is there an alternative method to damaging the player without relying on ‘.parent’?
Here is my code:
caster.RayHit:Connect(function(cast, result, velocity, bullet)
local hit = result.Instance
if hit then
if hit.Parent:FindFirstChild('Humanoid') and not hit:IsDescendantOf(char) then
local victimHum = hit.Parent.Humanoid
local victimAnimator = victimHum.Animator
victimHum:TakeDamage(15)
end
Debris:AddItem(bullet,2)
end
end)
local model = hit:FindFirstAncestorOfClass('Model')
if model and not hit:IsDescendantOf(char) then
local hum = model:FindFirstChildOfClass('Humanoid')
if hum then
end
end
caster.RayHit:Connect(function(cast, result, velocity, bullet)
local hit = result.Instance
if hit then
local hitModel = hit:FindFirstAncestorWhichIsA("Model")
if hitModel and hitModel ~= char then
local hitHuman = hit:FindFirstChildOfClass("Humanoid")
if hitHuman then
local hitAnim = hitHuman:FindFirstChildOfClass("Animator")
if hitAnim then
hitHuman:TakeDamage(15)
end
end
end
end
Debris:AddItem(bullet, 2)
end)