follow script covron
Key RequiredUniversal

follow script covron

Universal ScriptAbon0dandedAbon0danded 7K views 182 executesUpdated Feb 18, 2025
0.0/ 5(1 votes)
010% Positive
Lua Script•144 lines (4642 chars)
game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer("follow script by covron | commands: .f <user>, .unf <user>", "All")
local Players = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local following = false
local targetPlayer = nil
local targetJumpConn = nil
local targetCharAddedConn = nil

local pathFolder = workspace:FindFirstChild("PathVisuals") or Instance.new("Folder", workspace)
pathFolder.Name = "PathVisuals"

local function updateLocalCharacter(newCharacter)
	Character = newCharacter
	Humanoid = Character:WaitForChild("Humanoid")
	HRP = Character:WaitForChild("HumanoidRootPart")
end

LocalPlayer.CharacterAdded:Connect(updateLocalCharacter)

local function getPlayerByName(nameFragment)
	for _, player in ipairs(Players:GetPlayers()) do
		if player ~= LocalPlayer and string.find(player.Name:lower(), nameFragment:lower(), 1, true) then
			return player
		end
	end
	return nil
end

local function setupTargetJumpConnection(target)
	if targetJumpConn then
		targetJumpConn:Disconnect()
		targetJumpConn = nil
	end
	if targetCharAddedConn then
		targetCharAddedConn:Disconnect()
		targetCharAddedConn = nil
	end
	local function connectJumpEvent(character)
		local targetHumanoid = character:WaitForChild("Humanoid", 5)
		if targetHumanoid then
			targetJumpConn = targetHumanoid.Jumping:Connect(function(isActive)
				if isActive and following then
					if Humanoid and (Humanoid:GetState() == Enum.HumanoidStateType.Running or Humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics or Humanoid:GetState() == Enum.HumanoidStateType.Landed) then
						Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
					end
				end
			end)
		end
	end
	if target.Character then
		connectJumpEvent(target.Character)
	end
	targetCharAddedConn = target.CharacterAdded:Connect(function(newChar)
		RunService.Heartbeat:Wait()
		connectJumpEvent(newChar)
	end)
end

local function clearPathVisuals()
	for _, v in ipairs(pathFolder:GetChildren()) do
		v:Destroy()
	end
end

local function showPath(path)
	clearPathVisuals()
	local waypoints = path:GetWaypoints()
	for i, waypoint in ipairs(waypoints) do
		local part = Instance.new("Part")
		part.Shape = Enum.PartType.Ball
		part.Color = Color3.new(1, 0, 0)
		part.Size = Vector3.new(1, 1, 1)
		part.Anchored = true
		part.CanCollide = false
		part.Position = waypoint.Position
		part.Parent = pathFolder
		if i > 1 then
			local beamPart = Instance.new("Part")
			beamPart.Size = Vector3.new(0.2, 0.2, (waypoint.Position - waypoints[i-1].Position).Magnitude)
			beamPart.CFrame = CFrame.new((waypoint.Position + waypoints[i-1].Position) / 2, waypoint.Position)
			beamPart.Anchored = true
			beamPart.CanCollide = false
			beamPart.Color = Color3.new(0, 1, 0)
			beamPart.Parent = pathFolder
		end
	end
end

task.spawn(function()
	while true do
		if following and targetPlayer then
			if not (LocalPlayer.Character and targetPlayer.Character) then
				RunService.Heartbeat:Wait()
				continue
			end
			HRP = LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
			Humanoid = LocalPlayer.Character:FindFirstChild("Humanoid")
			local targetHRP = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
			if HRP and Humanoid and targetHRP then
				local path = PathfindingService:CreatePath({
					AgentRadius = 2,
					AgentHeight = 5,
					AgentCanJump = true,
					AgentJumpHeight = 7,
					AgentWalkableFloorAngle = 60
				})
				path:ComputeAsync(HRP.Position, targetHRP.Position)
				if path.Status == Enum.PathStatus.Success then
					showPath(path)
					local waypoints = path:GetWaypoints()
					for _, waypoint in ipairs(waypoints) do
						if not following then break end
						Humanoid:MoveTo(waypoint.Position)
						local reached = Humanoid.MoveToFinished:Wait()
						if not reached then break end
					end
				else
					Humanoid:MoveTo(targetHRP.Position)
				end
			end
		end
		RunService.Heartbeat:Wait()
	end
end)

LocalPlayer.Chatted:Connect(function(msg)
	if msg:sub(1, 3) == ".f " then
		local nameFragment = msg:sub(4):gsub("^%s*(.-)%s*$", "%1")
		local newTarget = getPlayerByName(nameFragment)
		if newTarget then
			targetPlayer = newTarget
			following = true
			setupTargetJumpConnection(targetPlayer)
		end
	elseif msg:lower() == ".unf" then
		following = false
		clearPathVisuals()
	end
end)

Features & Information

.f = follow .unf = unfollow by covron visuals Pathfinder
#Visual#Follow#Op#Script

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts