Parts that fly to the player

Hi im trying to make something similar to XP Orbs that fly to the player, right now im trying to use TweenService

for i, v in pairs(part.OreCubes:GetChildren()) do
  v.Anchored = false
  local tween = TweenService:Create(v, tweenInfo, {Position = char.HumanoidRootPart.Position})
  tween:Play()
end

This script only gets the player position once, how can i make it so it constantly gets the player position?
Should i even be using TweenService for this?
PS: I can not make a while loop that checks the player position since this is inside a Remote Event that gets fired every time a player clicks a specific part/“ore”.

I understand what you mean. When a player moves the orbs tween to the old player position. You can definitely fix that. I’m not sure if this will work if you put that whole for i, v loop inside a while wait() do loop. You can try using Lerp() as well https://devforum.roblox.com/t/cframe-lerp-how-to-use-it-properly/534389. I’m not sure if Lerp() function checks the position in real time but you could try.

I find it easier to use lerping with runservice because runservice has deltatime parameter so you can make adjustments to the alpha increment so it’s always in time.

1 Like

Consider using body position to achieve that -

You may want to update the destination position within a loop to keep it updated to the player position and trigger the “collect” when they reach close enough to the player.

Have you considered using BodyVelocity's and changing the velocity to the players root?

Okay but how do i constantly check the player position? Even if i do that and the player moves it will fly to the old position. Right now the script checks the the part HP is lower than 1 and if it is it unachores the parts. After they are unanchored i want them to fly towards the player and get destroyed once they hit him. I can do this but the only problem is constantly checking the player positon. This is inside a Remote Event so idk if i can/should use while loops to check the position?

I found out that i can do this using RocketPropulsion (roblox.com)

1 Like