The error is on line 16. The error outputted is: 'attempt to index nil with 'Parent'' Even if I put it inside an if statement, it still brings an error, and I'm not sure why.
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local shootEvent = events:WaitForChild("Shoot")
function newBullet(player,part,pos,damage)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid.Health > 0 then
humanoid:TakeDamage(damage)
end
else
local bullet = Instance.new("Part",workspace:WaitForChild("Ignore"))
bullet.Anchored = true
bullet.CanCollide = false
bullet.BrickColor = BrickColor.new("Black")
bullet.Position = pos
bullet.Size = Vector3.new(0.1,0.1,0.1)
game:GetService("Debris"):AddItem(bullet,5)
end
end
shootEvent.OnServerEvent:Connect(newBullet)

5 comments
do NOT use Instance.new("Part", workspace)
parenting your part like this is slow
not that it will fix the error but its just a suggestion to always do "object.parent" instead
you havent given your bullet any information about what its "Parent" might be i guess (line 6)
also you made a typo saying its line 16 instead of line 6