Gotcha.
So essentially what you need the body for is the magnitude from the root part to the fruit?
To be completely honest, I am not too sure what the issue could be but instead of trying to figure out why it isn’t working I’d like to offer a little bit of a solution.
I’m thinking the issue might derive from this line:
return (plrbody.Position - a.Position).magnitude > (plrbody.Position - b.Position).magnitude
So let’s create a function that gets a new Vector3 which is equal to the player’s HRP position instead of using plrBody
local function getLocalPlayerBodyPosition() -- you can shorten this, I just like using descriptive names whenever possible
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
return character:WaitForChild('HumanoidRootPart').Position
end
Then whenever plrbody.Position
appears in your script, replace it with getLocalPlayerBodyPosition()
For example,
return (getLocalPlayerBodyPosition() - a.Position).magnitude > (getLocalPlayerBodyPosition() - b.Position).magnitude
See if that helps.