I sometimes get “tried to index nil with position” when I punch a rig. Can somebody please help me, Thanks (This is only part of the code)
-- for _, plr in players:GetPlayers() do
local char = plr.Character
if char == nil or plr == player then continue end
if (char.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
coroutine.wrap(hit)(player, char, punchDamage)
break
end
end
for _, dummy in workspace.Dummies:GetChildren() do
if (dummy.PrimaryPart.Position - character.PrimaryPart.Position).Magnitude <= punchDistance then
coroutine.wrap(hit)(player, dummy, punchDamage)
break
end
end