Attempt to index number with number

  1. What do you want to achieve? I am making a egg hatching system
  2. What is the issue?
			if player:DistanceFromCharacter(nearestEgg.EggMesh.PrimaryPart.Position) < MaxDisplayDistance then
				canHatch = true
			else
				canHatch = false
			end

			if canHatch == true then
				local result = replicatedStorage:WaitForChild("EggHatchingRemotes"):WaitForChild("HatchServer"):InvokeServer(nearestEgg)
				if result ~= nil then
					print("hatch")
					hatchOne(result, nearestEgg)
					end
				else
					print("Cannot Hatch")
				end
			end
		end
	end)

when i press the error it shows up this line replicatedStorage:WaitForChild(“EggHatchingRemotes”):WaitForChild(“HatchServer”):InvokeServer(nearestEgg)

the error says ServerScriptService.Egg_System.Main_Server:5: attempt to index number with number

i get this error whenever i go to the egg and press E to hatch the animation doesnt show because of the error of “index number with number”

Is this a server script or local script?

if it’s a server script then you need to use InvokeClient
if it’s a local script you have to put the player parameter in InvokeServer

thank you for the response but i fixed it 30m later