Basically what I’m trying to achieve is making it so the part follows the NPC in the X axis so everytime the NPC moves the part will also move.
If you don’t want it to be smooth then the simplest way is to use RunService.Heartbeat (on server) or RunService.RenderStepped (client), either that or just a simple while loop.
Small example (server):
local NPC_RootPart --define the NPC's root part
local partThatFollowsNPC --define the part that should follow it
while wait(.1) do
partThatFollowsNPC.CFrame = NPC_RootPart.CFrame --set the part's cframe to the same cframe as the NPC's root part
end
If possible, you should definitely run this inside a local script and use .RenderStepped for smoother movement.
Oh and if you want it on only the X axis then just do :
partThatFollowsNPC.CFrame = CFrame.new(NPC_RootPart.CFrame.X, 0, 0)
1 Like
Thank you! It worked perfectly.
1 Like
