Basically my issue is that the GetChildren function seems to only be grabbing just a few of the parts in the folder.

print("Intalizing Eat Script")

local ReplicatedStorge = game:GetService("ReplicatedStorage")
local eatEvent = game.ReplicatedStorage.EatEvent

local player = game.Players.LocalPlayer
local character = player.Character

local stars = workspace.Food.Stars

local running = true
local ticks = 1

if character:findFirstChild("Humanoid") then
	local playerLocation = character.HumanoidRootPart.Position
		
	-- Main Loop		
	while running do
		-- Stars Variable
		local stars = workspace.Food.Stars:GetChildren()
		
		-- Loop Through Parts
		for i,Part in pairs(stars) do
			local magnitude = (playerLocation - Part.Position).magnitude
			
			if magnitude <= 300 then
				print(Part.Name, " - " ,magnitude)
				eatEvent:FireServer(Part)
				
			end
			
		end
		wait(1/ticks)
	end
	
	print("End Loop")
	
end

4 comments

2

Why did you post a pastebin rather than using the site's Lua converter?

0

GetChildren() will return an array of ALL of the parent's children. I do not think it's the method that has the problem, rather how you're using it. My guess is some of the children do not follow your conditional. You can always print() to have a 'visual' of all the children.

0

Edited to replace pastebin link with code