-- LocalScript (StarterPlayerScripts) -- Auto-collect everything under workspace.GameKeeper.Map.Pumpkins by -- teleporting the local R15 player to each Part/Model in that folder. local Players = game:GetService("Players") local ProximityPromptService = game:GetService("ProximityPromptService") local PATH = {"GameKeeper","Map","Pumpkins"} -- folder path in Workspace local Y_OFFSET = 3 -- appear a bit above target local TOUCH_TIME = 0.25 -- how long to sit on each item local BETWEEN_TIME = 0.1 -- small gap between teleports local function waitForCharacter(plr) local char = plr.Character or plr.CharacterAdded:Wait() char:WaitForChild("Humanoid") char:WaitForChild("HumanoidRootPart") return char end local function isR15(char) local hum = char:FindFirstChildOfClass("Humanoid") return hum and hum.RigType == Enum.HumanoidRigType.R15 end local function getByPath(root, names) local inst = root for _, name in ipairs(names) do inst = inst:WaitForChild(name) end return inst end local function getModelCF(m) -- Prefer pivot; fall back to PrimaryPart; then first BasePart local ok, cf = pcall(function() return m:GetPivot() end) if ok and cf then return cf end if m.PrimaryPart then return m.PrimaryPart.CFrame end local p = m:FindFirstChildWhichIsA("BasePart", true) return p and p.CFrame or nil end local function getTouchPart(inst) if inst:IsA("BasePart") then return inst end if inst:IsA("Model") then return inst.PrimaryPart or inst:FindFirstChildWhichIsA("BasePart", true) end return nil end local function triggerPrompts(inst) for _, d in ipairs(inst:GetDescendants()) do if d:IsA("ProximityPrompt") and d.Enabled then pcall(function() ProximityPromptService:TriggerPrompt(d) end) end end end local function buildTargets(folder) local t = {} for _, child in ipairs(folder:GetChildren()) do if child:IsA("BasePart") or child:IsA("Model") then table.insert(t, child) end end -- deterministic order so it doesn't jump around randomly table.sort(t, function(a,b) return a.Name < b.Name end) return t end local function collectAll() local player = Players.LocalPlayer local char = waitForCharacter(player) if not isR15(char) then warn("This script expects an R15 rig.") end local hrp = char:FindFirstChild("HumanoidRootPart") -- Locate workspace.GameKeeper.Map.Pumpkins local pumpkinsFolder = getByPath(workspace, PATH) local targets = buildTargets(pumpkinsFolder) for _, inst in ipairs(targets) do if not inst or not inst.Parent then continue end local cf = inst:IsA("BasePart") and inst.CFrame or getModelCF(inst) local touchPart = getTouchPart(inst) if not cf or not touchPart then continue end -- Teleport above, then onto the object (to ensure a touch) local above = cf.Position + Vector3.new(0, Y_OFFSET, 0) hrp.CFrame = CFrame.new(above, above + cf.LookVector) task.wait(0.05) hrp.CFrame = CFrame.new(touchPart.Position, touchPart.Position + cf.LookVector) -- Try to fire any ProximityPrompts on/inside this object triggerPrompts(inst) -- Wait briefly for collection scripts to run, or until the object is removed local t0 = os.clock() while os.clock() - t0 < TOUCH_TIME and inst and inst.Parent do task.wait(0.05) end task.wait(BETWEEN_TIME) end end -- Run once on spawn; run again if you respawn. local running = false local function onSpawn() if running then return end running = true pcall(collectAll) running = false end local plr = Players.LocalPlayer if plr.Character then task.defer(onSpawn) end plr.CharacterAdded:Connect(onSpawn)