I’ve been trying this for quite a while, probably made 5 posts about different parts of it, and had no luck. I’m trying to make a sort of “wall-hug” npc function, to do obbies like this:
If you don’t know how to do this, you basically use shift lock, line yourself up with the part, and then slowly change your camera in the direction you want to go to get there. The problem with NPCs is, well, they don’t have “shift-lock”, and (as far as I know, if I’m wrong, please tell me) I can’t just emulate movement. (Like “W” presses). I’m not even sure if this is possible, but I’ve been trying for quite a while. I’m just wondering if anyone has ever done anything like this successfully?
Here's my currently sort-of messy code, and it's my best attempt at making this work
--Services --Other local obbyModel = game.Workspace.ObbyTest local npcClone = game.ReplicatedStorage:WaitForChild("Dummy"):Clone() npcClone.HumanoidRootPart.Position = obbyModel.StartPart.Position + Vector3.new(0,4,0) npcClone.Parent = game.Workspace npcClone.Humanoid:MoveTo(obbyModel.Path1.Position) local jumped = false local endTouched local loopTimes = 0 local function testJump(humanoid) humanoid.Jump = true jumped = true end obbyModel.JumpPart.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then testJump(hit.Parent.Humanoid) end end) repeat wait() until jumped == true npcClone.Humanoid:MoveTo(obbyModel.Path2.Position) wait(.15) --Wallhug local animator = Instance.new("Animator") animator.Name = "Animator" animator.Parent = npcClone.Humanoid local animationInstance = Instance.new("Animation") animationInstance.AnimationId = "rbxassetid://7148106034" animationInstance.Parent = npcClone.Humanoid while true do npcClone.HumanoidRootPart.Orientation = Vector3.new(obbyModel.BackWallTop.Orientation.X ,obbyModel.BackWallTop.Orientation.Y + 180,obbyModel.BackWallTop.Orientation.Z ) npcClone.Torso.Orientation = Vector3.new(obbyModel.BackWallTop.Orientation.X ,obbyModel.BackWallTop.Orientation.Y + 180,obbyModel.BackWallTop.Orientation.Z ) npcClone.Humanoid:MoveTo(Vector3.new(npcClone.HumanoidRootPart.Position.X,npcClone.HumanoidRootPart.Position.Y,npcClone.HumanoidRootPart.Position.Z + 1)) --local loadedAnimation = animator:LoadAnimation(animationInstance) --loadedAnimation:Play() --loadedAnimation.Stopped:Connect(function() -- --npcClone.HumanoidRootPart.CFrame = npcClone.Torso.CFrame --end) --loadedAnimation.Stopped:Wait() --npcClone.Humanoid:MoveTo(obbyModel.PathfindingGoal.Position) wait() end wait(5) wait(1)
And I’m not using animations because I cannot include jumping and gravity as a factor, and it just needs to be really precise if that was a thing as well