Why is my pathfinding doing this?

I’m making a button that clones your character, it walks to you from a weird chamber thing, and speaks. The pathfinding… err… works, it’s just… jagged? The thing is, it looks perfectly fine in Studio, but not in-app.

You can see that, starting out, it moves smoothly. But after that it seems like it’s unsure it wants to go there. (this is recorded from in-app)
ezgif-2-242f8da459

My server-script for cloning. I’ve commented the pathfinding parts.

local CS = game:GetService("Chat")
local PFS = game:GetService("PathfindingService")
local TS = game:GetService("TweenService")

script.Parent.ClickDetector.MouseClick:Connect(function(clicked)
	local char = clicked.Character
	if char then
		script.Parent.Activate:Play()
		char.Archivable = true
		local clone = char:Clone()
		clone.HumanoidRootPart.CFrame = CFrame.new(-106.960472, 3, -7.83596659, 0, 0, -1, 0, 1, 0, 1, 0, 0)
		clone.Parent = game.Workspace.PlayerClones
		clone.Name = char.Name.." Clone"
		
		char.Archivable = false
		
		local path = PFS:CreatePath()	-- pathfindingrelated
		path:ComputeAsync(clone.HumanoidRootPart.Position, char.HumanoidRootPart.Position - Vector3.new(7, 0, 0))  -- pathfindingrelated
		
		if clone:FindFirstChild("Animate") then
			clone.Animate:Destroy()
			local animclone = script.Animate:Clone()
			animclone.Parent = clone
			animclone.Enabled = true
		end
		
		if clone:FindFirstChild("ForceField") then
			clone.ForceField:Destroy()
			clone.HumanoidRootPart.Particles:Destroy()
		end
		
		local waypoints = path:GetWaypoints() -- pathfindingrelated
		
		for i, waypoint in pairs(waypoints) do -- pathfindingrelated
			clone.Humanoid:MoveTo(waypoint.Position) -- pathfindingrelated
			clone.Humanoid.MoveToFinished:Wait() -- pathfindingrelated
		end
		
		wait(0.5)
		TS:Create(clone.HumanoidRootPart, TweenInfo.new(0.3), 
			{ CFrame = CFrame.lookAt(clone.HumanoidRootPart.Position, char.HumanoidRootPart.Position) }
		):Play()
		
		local destroyclone = script.DestroyClone:Clone()
		destroyclone.Parent = clone
		destroyclone.Enabled = true
		
		if clone.Head then
			local sound = script.Parent.Chat:Clone()
			sound.Parent = clone.Head
			CS:Chat(clone.Head, "Hello, creator!", Enum.ChatColor.Blue)
			sound:Play()
		end
		
		if #game.Workspace.PlayerClones:GetChildren() >= 15 then
			clone:Destroy()
			print("Deleted "..clicked.DisplayName.."'s clone. Sorry, but there are currently too many clones in the server.")
		end
		
	end
end)

See for yourself here.

1 Like

you didnt setnetworkowner to nil, clone.HumanoidRootPart:SetNetworkOwner(nil)

3 Likes

Never would’ve thought to do such a thing if it weren’t for this reply. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.