Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local char = Instance.new("Model" , script)
- char.Name = "Pathfinding Dummy"
- local hed = Instance.new("Part", char)
- hed.Name = "Head"
- hed.Size = Vector3.new(1,1,1)
- local ro = Instance.new("RemoteEvent",owner.PlayerGui)
- ro.Name = "The"
- local dead = false
- owner.Character.Head.Mesh:Clone().Parent = hed
- local dc = Instance.new("Decal",hed)
- dc.Face = "Front"
- dc.Texture = "rbxassetid://2773283257"
- local tors = Instance.new("Part", char)
- tors.Name = "Torso"
- tors.Size = Vector3.new(2,2,1)
- local hedw = Instance.new("Motor6D", tors)
- hedw.Part0 = tors
- hedw.Part1 = hed
- hedw.Name = "Neck"
- hedw.C0 = CFrame.new(0,0.5,0)
- hedw.C1 = CFrame.new(0,-1,0)
- local p2 = Instance.new("Part", char)
- p2.Name = "HumanoidRootPart"
- p2.Size = Vector3.new(2,2,1)
- p2.Material = "SmoothPlastic"
- p2.Transparency = 1
- p2.CanCollide = false
- local fake = p2
- local ra = Instance.new("Part", char)
- ra.Name = "Right Arm"
- ra.CanCollide = false
- ra.Size = Vector3.new(1,2,1)
- local la = Instance.new("Part", char)
- la.Name = "Left Arm"
- la.CanCollide = false
- la.Size = Vector3.new(1,2,1)
- local ll = Instance.new("Part", char)
- ll.Name = "Left Leg"
- ll.CanCollide = false
- ll.Size = Vector3.new(1,2,1)
- local rl = Instance.new("Part", char)
- rl.Name = "Right Leg"
- rl.CanCollide = false
- rl.Size = Vector3.new(1,2,1)
- local torswe = Instance.new("Motor6D", fake)
- torswe.Part0 = fake
- torswe.Part1 = tors
- torswe.Name = "Root Joint"
- torswe.C0 = owner.Character.HumanoidRootPart["RootJoint"].C0
- torswe.C1 = owner.Character.HumanoidRootPart["RootJoint"].C1
- local a = Instance.new("Motor6D" , tors)
- a.Name = "Right Shoulder"
- a.Part0 = tors
- a.Part1 = ra
- a.C0 = owner.Character.Torso["Right Shoulder"].C0
- a.C1 = owner.Character.Torso["Right Shoulder"].C1
- local aaa = Instance.new("Motor6D" , tors)
- aaa.Name = "Left Shoulder"
- aaa.Part0 = tors
- aaa.Part1 = la
- aaa.C0 = owner.Character.Torso["Left Shoulder"].C0
- aaa.C1 = owner.Character.Torso["Left Shoulder"].C1
- local aa = Instance.new("Motor6D" , tors)
- aa.Name = "Left Hip"
- aa.Part0 = tors
- aa.Part1 = ll
- aa.C0 = owner.Character.Torso["Left Hip"].C0
- aa.C1 = owner.Character.Torso["Left Hip"].C1
- local aaaa = Instance.new("Motor6D" , tors)
- aaaa.Name = "Right Hip"
- aaaa.Part0 = tors
- aaaa.Part1 = rl
- aaaa.C0 = owner.Character.Torso["Right Hip"].C0
- aaaa.C1 = owner.Character.Torso["Right Hip"].C1
- local scri1 = Instance.new("Script" , char)
- scri1.Name = "Health"
- local idle = false
- local scri3 = Instance.new("Script" , char)
- scri3.Name = "Sound"
- char.PrimaryPart = fake
- owner.Character.Archivable = true
- local hum = Instance.new("Humanoid")
- hum.Parent = char
- hum.Name = "Humanoid"
- hum.RequiresNeck = false
- hum.DisplayName = "Pathfinding Dummy"
- hum.MaxHealth = 100
- hum.Health = 100
- hum.BreakJointsOnDeath = false
- hum.AutoJumpEnabled = true
- local object = Instance.new("ObjectValue", owner.PlayerGui)
- object.Value = char
- object.Name = "Model"
- local bc = Instance.new("BodyColors",char)
- bc.HeadColor3 = Color3.new(242/255, 243/255, 243/255)
- bc.RightArmColor3 = Color3.new(242/255, 243/255, 243/255)
- bc.LeftArmColor3 = Color3.new(242/255, 243/255, 243/255)
- bc.LeftLegColor3 = Color3.new(253/255, 166/255, 53/255)
- bc.RightLegColor3 = Color3.new(253/255, 166/255, 53/255)
- bc.TorsoColor3 = Color3.new(253/255, 166/255, 53/255)
- for i,v in pairs(char:GetDescendants()) do
- if v:IsA("Part") then
- v:SetNetworkOwner(owner)
- end
- end
- wait()
- p2.CFrame = owner.Character.Head.CFrame
- Instance.new("Animator",hum).Name = "Animator"
- function onDied()
- dead = true
- for i, v in pairs (hum:GetPlayingAnimationTracks()) do
- v:Stop()
- end
- local ss = Instance.new("Sound",hed)
- local sounds = {"4755480391","4523373375","2618158728","5525467333","856379539","5438872876"}
- local rand = sounds[math.random(1,6)]
- ss.SoundId = "rbxassetid://"..rand
- ss.Volume = 1.5
- ss:Play()
- game:GetService("Debris"):AddItem(char,game:GetService("Players").RespawnTime)
- end
- local animationTrack = hum.Animator:LoadAnimation(owner.Character.Animate.run.RunAnim)
- animationTrack.Looped = true
- animationTrack.Priority = Enum.AnimationPriority.Movement
- local animationTrack4 = hum.Animator:LoadAnimation(owner.Character.Animate.idle.Animation1)
- animationTrack4.Looped = true
- animationTrack4.Priority = Enum.AnimationPriority.Idle
- animationTrack4:Play()
- local animationTrack3 = hum.Animator:LoadAnimation(owner.Character.Animate.fall.FallAnim)
- animationTrack3.Looped = true
- animationTrack3.Priority = Enum.AnimationPriority.Movement
- local animationTrack2 = hum.Animator:LoadAnimation(owner.Character.Animate.jump.JumpAnim)
- animationTrack2.Priority = Enum.AnimationPriority.Movement
- animationTrack:Play()
- function jump()
- animationTrack2:Play()
- animationTrack:Stop()
- end
- function stopf(ol,ne)
- if ne == Enum.HumanoidStateType.Landed or ol == Enum.HumanoidStateType.Freefall then
- animationTrack3:Stop()
- if not idle then
- animationTrack:Play()
- end
- elseif ne == Enum.HumanoidStateType.Freefall then
- animationTrack2:Stop()
- animationTrack3:Play()
- end
- end
- hum.Died:Connect(onDied)
- hum.StateChanged:Connect(stopf)
- hum.Jumping:Connect(jump)
- coroutine.wrap(function()
- while task.wait() do
- if hum.Sit == true then
- hum.Jump = true
- end
- animationTrack:AdjustSpeed(char:FindFirstChildWhichIsA("Part").Velocity.Magnitude / hum.WalkSpeed)
- if char:FindFirstChildWhichIsA("Part").Velocity.Magnitude == 0 then
- animationTrack:Stop()
- idle = true
- else
- if idle and not dead then
- idle = false
- animationTrack:Play()
- end
- end
- end
- end)()
- for i,v in pairs(owner.Character.Animate:GetChildren()) do
- local cl = v:Clone()
- cl.Parent = scri2
- end
- NLS([[
- local model = owner.PlayerGui.Model.Value
- found = true
- local lastknownposition
- humanoid = model.Humanoid
- roombas = {model}
- part = model.Torso
- lastknownposition = Vector3.new()
- function wallcheck(who,mod)
- coroutine.wrap(function()
- pcall(function()
- iforgor = {}
- local raycastParams = RaycastParams.new()
- raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
- raycastParams.FilterDescendantsInstances = {roombas,who,mod}
- raycastParams.IgnoreWater = true
- local result = workspace:Raycast(part.Position + Vector3.new(0,-0.5,0), CFrame.new(part.Position,who.Position).lookVector * (part.Position - who.Position).Magnitude, raycastParams)
- if result then
- table.insert(iforgor,mod)
- else
- lastknownposition = who.CFrame * CFrame.new(0,0,2)
- end
- end)
- end)()
- return iforgor
- end
- function move(destination,wher)
- coroutine.wrap(function()
- if wher ~= false then
- local PathfindingService = game:GetService("PathfindingService")
- local path = PathfindingService:CreatePath({
- AgentRadius = 7,
- AgentHeight = 5,
- AgentCanJump = true,
- WaypointSpacing = 0.75,
- Costs = {
- }
- })
- local waypoints
- local nextWaypointIndex
- local reachedConnection
- local blockedConnection
- local success, errorMessage = pcall(function()
- path:ComputeAsync(part.Position, destination)
- end)
- if success and path.Status == Enum.PathStatus.Success then
- waypoints = path:GetWaypoints()
- blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)
- if blockedWaypointIndex >= nextWaypointIndex then
- blockedConnection:Disconnect()
- move(destination)
- end
- end)
- if not reachedConnection then
- reachedConnection = humanoid.MoveToFinished:Connect(function(reached)
- if reached and nextWaypointIndex < #waypoints then
- nextWaypointIndex = nextWaypointIndex + 1
- if waypoints[nextWaypointIndex].Action == Enum.PathWaypointAction.Walk then
- humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
- else
- humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
- coroutine.wrap(function()
- wait(0.125)
- humanoid.Jump = true
- end)()
- end
- elseif reached and nextWaypointIndex >= #waypoints then
- found = true
- reachedConnection:Disconnect()
- blockedConnection:Disconnect()
- end
- end)
- end
- nextWaypointIndex = 1
- humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
- else
- move(destination,true)
- end
- else
- humanoid:MoveTo(destination)
- end
- end)()
- end
- local function findNearestTorso(pos)
- local list = game.Workspace:GetChildren()
- local torso = nil
- local dist = 75
- local temp = nil
- local human = nil
- local temp2 = nil
- for x = 1, #list do
- temp2 = list[x]
- if (temp2.className == "Model") and (temp2 ~= model) then
- temp = temp2:findFirstChild("Torso")
- human = temp2:findFirstChild("Humanoid")
- if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
- if (temp.Position - pos).magnitude < dist then
- torso = temp
- mod = temp2
- dist = (temp.Position - pos).magnitude
- end
- end
- end
- end
- return torso, mod
- end
- while true do
- local torso, mod = findNearestTorso(part.Position)
- local iforgor = wallcheck(torso,mod)
- if table.find(iforgor,mod) and torso ~= nil then
- move(lastknownposition.Position)
- found = false
- repeat
- wait()
- until found == true
- elseif torso ~= nil then
- local pos = torso.CFrame * CFrame.new(0,0,2)
- move(pos.Position,false)
- end
- task.wait()
- end
- ]],owner.PlayerGui)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement