i want a model to follow neares player,
i tried using linear velocity but it wasnt good for whole models,
this is billy, he generates legs after i run the game, and if model moves far, legs will follow it using bezier curves,
so only thing i need is to make this model follow players using cframe,
after this im gonna script some attacking tentacles so he can kill players but first he has to come close to players,
im trying to make him use crframes and im calling him a model, because he is not rigged and it doesnt has humanoid, i can add humanoid but it wont have legs, torso, head, arms, or i wont be able to rig and animate him, so i need a basic model cframe follow script that detects neares player, i would appreciate all help and i can pay for the script!
Since it’s not using a humanoid, I’m guessing the best approach would probably be to use TweenService for moving to the player, however I’m not sure how walk animations would work but I’ll leave that up to you.
As for finding the nearest player, you can use RayCasting if you want the model to have a limited vision radius, and Magnitude to calculate the distance of each player from the model.
youre gonna want to connect it to an invisible humanoidrootpart and get proper motor6ds on them, itll make your life so much easier doing all of the work in a humanoid rather entirely thru script
i wont add animations, this is the main problem, its not a rig i cant use pathfinding and moveto() so i need a way to make model to follow player but only in X and Z not in Y position
you can use weld constraint to make them all welded then put this script:
local model = --put your model here
local Y = --put your Y position you want here since you don't wanna change it
local player = --put your player here
while task.wait() do
-- pcall because player character might not load on time and im too lazy to put all those conditions
pcall(function()
model:MoveTo(Vector3.new(player.Character.HumanoidRootPart.Position.X+10,Y,player.Character.HumanoidRootPart.Position.Z+10))
end)
end
ok i made it find the neares player, and then use your script, but it just teleports on the players head, and it changes Y pos even if i set it 111 or 0
local Y = 0
local function FindNearestPlayer(position)
local found
local last = math.huge
for _,plyr in pairs(game.Players:GetPlayers()) do
local distance = plyr:DistanceFromCharacter(position)
if distance < last then
found = plyr
last = distance
end
end
return found
end
while task.wait(2) do
local player = FindNearestPlayer(script.Parent.HumanoidRootPart.Position)
pcall(function()
model:MoveTo(Vector3.new(player.Character.HumanoidRootPart.Position.X,Y,player.Character.HumanoidRootPart.Position.Z))
end)
end```