Whenever I get the parent of the mouse’s target to check if it’s got a humanoid child, it gives the error ‘Attempt index nil with Parent’. Anyone got any ideas?
if Mouse.Target.Parent:FindFirstChild("Humanoid") then
script.Parent.DealDamage:FireServer(Mouse.Target.Parent, 5)
end
If you’re pointing in the air, it will return nil for mouse.Target, I would recommend checking if Mouse.target exists first before checking the parent property
local target = Mouse.Target
if target and target.Parent:FindFirstChild("Humanoid") then
script.Parent.DealDamage:FireServer(target.Parent, 5)
end
I also recommend against having a RemoteEvent to deal an arbitrary amount of damage to any humanoid. That seems like a major security flaw that any exploiters would take advantage of.