Attempt to index nil with position

  1. What is the issue? Whenever the Egg is too far away from the player it gives the error (Attempt to index nil with position)

  2. What solutions have you tried so far? Ive looked around devforum but no one has the same problem

		runService.RenderStepped:Connect(function()
			if player:DistanceFromCharacter(v.EggMesh.PrimaryPart.Position) < MaxDisplayDistance then
				if cantOpenBillboard == false then
					billboardTemp.Enabled = true
					animateBillboard(billboardTemp, true)
				end
			else
				if cantOpenBillboard == false then

					animateBillboard(billboardTemp, false)
				end
			end
		end)
	end
end

I assume you have enabled StreamingEnabled?
The reason it errors is because the egg is ‘unloaded’ and as such the script does not know that it exists, hence the error.

You can try to resolve this by checking if the egg exists first:

runService.RenderStepped:Connect(function()
            if not v.EggMesh.PrimaryPart then return end
			if player:DistanceFromCharacter(v.EggMesh.PrimaryPart.Position) < MaxDisplayDistance then
				if cantOpenBillboard == false then
					billboardTemp.Enabled = true
					animateBillboard(billboardTemp, true)
				end
			else
				if cantOpenBillboard == false then

					animateBillboard(billboardTemp, false)
				end
			end
		end)
	end
end

Turns out it was streaming enabled. I have turned it off for now but I dont know how efficient this will be for the future but thanks though!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.