Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _G.follow(times)
- for i = 1, times do
- task.wait()
- local part1 = Instance.new("Part", game.Workspace)
- part1.Size = Vector3.new(1.487, 0.985, 2.72)
- local bg = Instance.new("BodyGyro",part1)
- bg.D = 100
- bg.P = 1000000000
- bg.MaxTorque = Vector3.new(1000000,1000000,1000000)
- local velocitylol = Instance.new("BodyVelocity", part1)
- coroutine.wrap(function()
- while true do
- task.wait()
- velocitylol.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- velocitylol.Velocity = part1.CFrame.LookVector * -32
- end
- end)()
- function move(target)
- local dir = (part1.Position - target.Position).unit
- local spawnPos = part1.Position
- local pos = spawnPos + (dir * 1)
- bg.cframe = CFrame.new(pos, pos + dir)
- end
- function findNearestTorso(pos)
- local list = game.Workspace:GetChildren()
- local torso = nil
- local dist = 1000
- local temp = nil
- local human = nil
- local temp2 = nil
- for x = 1, #list do
- temp2 = list[x]
- if (temp2.className == "Model") and (temp2 ~= script.Parent) then
- temp = temp2:findFirstChild("Head")
- human = temp2:findFirstChild("Humanoid")
- if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
- if (temp.Position - pos).magnitude < dist then
- torso = temp
- dist = (temp.Position - pos).magnitude
- end
- end
- end
- end
- return torso
- end
- coroutine.wrap(function()
- while true do
- local torso = findNearestTorso(part1.Position)
- if torso~=nil then
- move(torso)
- end
- task.wait()
- end
- end)()
- end
- end
Add Comment
Please, Sign In to add comment