Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drone = script.Parent.Parent
- local eng = script.Parent.Engine
- local trail = script.Parent.Fire
- local track = script.Parent.Track
- local target = ""
- local backup = drone:Clone()
- local parts = {track, eng, trail}
- local c = drone.BodyKit:GetChildren()
- for i = 1, #c do
- table.insert(parts, c[i])
- end
- function found(maxDistance)
- if connection ~= nil then
- connection:disconnect()
- end
- local c = game.Workspace:GetChildren()
- local ore = {}
- for i = 1, #c do
- if c[i]:FindFirstChild("Htitanium") ~= nil and c[i] ~= target and c[i].Htitanium.Health > 0 then
- table.insert(ore, c[i])
- end
- end
- local a = 100
- for i = 1, #ore do
- local dist = (ore[i].Ore.Position - eng.Position).magnitude
- if dist < a then
- a = dist
- end
- end
- for i = 1, #ore do
- if(ore[i].Ore.Position - eng.Position).magnitude == a then
- target = ore[i]
- end
- end
- connection = target.Htitanium.Died:connect(found)
- end
- function clean()
- wait(0.5)
- script.Parent = workspace
- drone:Remove()
- local c = backup:Clone()
- wait(2.5)
- c.Parent = workspace
- c:MakeJoints()
- script:Remove()
- end
- while true do
- if (eng.Position - track.Position).magnitude >= 10 then
- eng.BodyPosition.maxForce = Vector3.new(0,0,0)
- track:BreakJoints()
- for i = 1, #parts do
- parts[i].RotVelocity = Vector3.new(math.random(-25,25),math.random(-25,25),math.random(-25,25))
- parts[i].CFrame = eng.CFrame + Vector3.new(math.random(-2,2),math.random(-2,2),math.random(-2,2))
- local bv = Instance.new("BodyVelocity")
- bv.Parent = parts[i]
- bv.velocity = parts[i].Position - eng.Position
- end
- clean()
- break
- end
- eng.BodyPosition.position = eng.Position + eng.CFrame.lookVector
- found()
- if target ~= "" then
- eng.BodyGyro.cframe = CFrame.new(eng.Position, target.Ore.Position)
- end
- wait(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment