server:

local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local CoreEvent = ReplicatedStorage:WaitForChild("CoreEvent")
local conveyor = workspace:WaitForChild("Conveyor")
local waypointsFolder = conveyor:WaitForChild("WayPoints")
local eggsFolder = ReplicatedStorage:WaitForChild("Eggs")

local spawnInterval = 3 -- how many to spawn setting up this mess it up 
local moveTime = 1 -- speed of the egg 

local waypoints = {}
for _, wp in ipairs(waypointsFolder:GetChildren()) do
	local num = tonumber(wp.Name)
	if num then
		table.insert(waypoints, wp)
	end
end
table.sort(waypoints, function(a, b)
	return tonumber(a.Name) < tonumber(b.Name)
end)

local firstWaypoint = waypoints[1]

local function getRandomEgg()
	local total = 0
	for _, egg in ipairs(eggsFolder:GetChildren()) do
		local chance = egg:FindFirstChild("SpawnChance")
		if chance and chance:IsA("NumberValue") then
			total += chance.Value
		end
	end

	if total == 0 then return nil end

	local pick = math.random() * total
	local running = 0

	for _, egg in ipairs(eggsFolder:GetChildren()) do
		local chance = egg:FindFirstChild("SpawnChance")
		if chance then
			running += chance.Value
			if pick <= running then
				return egg
			end
		end
	end
end

local function moveModelSmooth(model, targetCFrame)
	local cframeVal = Instance.new("CFrameValue")
	cframeVal.Value = model:GetPivot()

	cframeVal.Changed:Connect(function(newCFrame)
		model:PivotTo(newCFrame)
	end)

	local tween = TweenService:Create(cframeVal, TweenInfo.new(moveTime, Enum.EasingStyle.Linear), {
		Value = targetCFrame
	})

	tween:Play()
	tween.Completed:Connect(function()
		cframeVal:Destroy()
	end)

	return tween
end

local function moveEgg(eggModel)
	coroutine.wrap(function()
		for i = 2, #waypoints do
			local baseCF = waypoints[i].CFrame
			local rotatedCF = baseCF * CFrame.Angles(0, 0, math.rad(90)) -- consistent rotation
			moveModelSmooth(eggModel, rotatedCF).Completed:Wait()
		end
		eggModel:Destroy()
	end)()
end

for _, v in pairs(workspace:GetChildren()) do
	if v:FindFirstChild("Owner") then
		local Base = v

		Base.LockBase.Touched:Connect(function(Hit)
			if Hit.Parent.Name == Base.Owner.Value and not Base.LockBase.IsLocked.Value then
				Base.LockBase.IsLocked.Value = true
				CoreEvent:FireAllClients("LockBase", Base)

				task.delay(60, function()
					Base.LockBase.IsLocked.Value = false
				end)
			end
		end)
	end
end

game.Players.PlayerAdded:Connect(function(plr)
	for _, v in pairs(workspace:GetChildren()) do
		if v:FindFirstChild("Owner") and v.Owner.Value == "None" then
			v.Owner.Value = plr.Name
			v.Sign.SignGUI.SignTextLabel.Text = plr.Name.."'s Base"
			break
		end
	end

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr

	local Steals = Instance.new("NumberValue")
	Steals.Name = "Steals"
	Steals.Value = 0
	Steals.Parent = leaderstats

	local Rebirths = Instance.new("NumberValue")
	Rebirths.Name = "Rebirths"
	Rebirths.Value = 0
	Rebirths.Parent = leaderstats

	local Cash = Instance.new("NumberValue")
	Cash.Name = "Cash"
	Cash.Value = 100
	Cash.Parent = leaderstats
end)

while true do
	local template = getRandomEgg()
	if template then
		local clone = template:Clone()
		clone.Parent = workspace

		if not clone.PrimaryPart then
			clone:Destroy()
		else
			local baseCF = firstWaypoint.CFrame
			local rotatedCF = baseCF * CFrame.Angles(0, 0, math.rad(90)) -- spawn rotation
			clone:PivotTo(rotatedCF)
			moveEgg(clone)
		end
	end
	task.wait(spawnInterval)
end

local:

local CoreEvent = game.ReplicatedStorage:WaitForChild("CoreEvent")
local Player = game.Players.LocalPlayer
local CoreGUI = Player:WaitForChild("PlayerGui"):WaitForChild("CoreGUI")

local function waitForChildTimeout(parent, childName, timeout)
	local start = os.clock()
	repeat
		local child = parent:FindFirstChild(childName)
		if child then return child end
		task.wait(0.1)
	until os.clock() - start > timeout
	return nil
end

local leaderstats = waitForChildTimeout(Player, "leaderstats", 5)
local Cash = leaderstats and waitForChildTimeout(leaderstats, "Cash", 5)

CoreEvent.OnClientEvent:Connect(function(eventtype, Argi1)
	if eventtype == "LockBase" then
		local Base = Argi1

		if Base.Owner.Value ~= Player.Name then
			Base.WallLock.CanCollide = true
		end

		for _, v in pairs(Base.Lasers:GetChildren()) do
			v.Transparency = 0.5
		end

		for i = 60, 0, -1 do
			Base.LockBase.LockGUI.LockTextLabel.Text = i .. " second(s)"
			task.wait(1)
		end

		for _, v in pairs(Base.Lasers:GetChildren()) do
			v.Transparency = 1
		end

		Base.WallLock.CanCollide = false
		Base.LockBase.LockGUI.LockTextLabel.Text = "Lock Base"
	end
end)

Cash.Changed:Connect(function()
	CoreGUI.MoneyTextLabel.Text = "$" .. Cash.Value
end)

can u make it so u can hold e to pickup the eggs, and u can bring them to your base, and based off how much the eggs cost u lose that amount of cash, and if u dont have enough ffor the egg nothing happens