Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local tractorName = player.Name .. " Tractor"
- local cropName = "Crop"
- local autoDungeonEnabled = true
- local tractor = workspace.Tractors:FindFirstChild(tractorName)
- local crops = workspace.Crops.DungeonCrops
- local specialCaseValue = tractor:FindFirstChild("SpecialCase")
- if not specialCaseValue then
- specialCaseValue = Instance.new("BoolValue")
- specialCaseValue.Name = "SpecialCase"
- specialCaseValue.Parent = tractor
- print("SpecialCaseValue Initial:", specialCaseValue and specialCaseValue.Value)
- end
- local function getTractorType(tractor)
- local body = tractor:FindFirstChild("Body")
- local specialCaseValue = tractor:FindFirstChild("SpecialCase")
- if specialCaseValue and specialCaseValue:IsA("BoolValue") and specialCaseValue.Value then
- return 2
- elseif body and (body:IsA("MeshPart") or body:IsA("Part")) then
- return 2
- else
- return 1
- end
- end
- local tractorType = getTractorType(tractor)
- local function findAndMoveTractor(model, name)
- for _, part in ipairs(model:GetChildren()) do
- if part:IsA("MeshPart") and part.Name == name and part.Transparency < 1 then
- if autoDungeonEnabled then
- for _, subPart in ipairs(part:GetChildren()) do
- if subPart:IsA("Part") or subPart:IsA("MeshPart") then
- subPart.CanCollide = false
- end
- end
- local currentHeight = tractor.PrimaryPart.Position.Y
- local distance = (tractor.PrimaryPart.Position - part.Position).Magnitude
- local partHeight = part.Position.Y
- local newX, newZ
- if tractorType == 1 or (tractorType == 2 and not specialCaseValue.Value) then
- newX = part.Position.X
- newZ = part.Position.Z + 11
- elseif tractorType == 2 and specialCaseValue.Value then
- newX = part.Position.X + 11
- newZ = part.Position.Z
- end
- if distance <= 350 and math.abs(currentHeight - partHeight) <= 30 then
- tractor:SetPrimaryPartCFrame(CFrame.new(Vector3.new(newX, currentHeight, newZ)))
- repeat
- wait(0.1)
- until part.Transparency >= 1
- findAndMoveTractor(model, name)
- end
- end
- return
- elseif part:IsA("Model") or part:IsA("Folder") then
- findAndMoveTractor(part, name)
- end
- end
- end
- local function onFileChanged(child, added)
- if autoDungeonEnabled then
- task.wait(0.1)
- findAndMoveTractor(crops, cropName)
- end
- end
- crops.ChildAdded:Connect(function(child)
- onFileChanged(child, true)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement