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
code
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()
code
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
code
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
while true do
local template = getRandomEgg()
if template then
local clone = template:Clone()
clone.Parent = workspace
code
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
code
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
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
Assistant
To implement egg pickup with "E" key, carry to base, and cash deduction based on egg value, you'll need to:
Add a Cost NumberValue to each egg in ReplicatedStorage.Eggs.
Detect "E" key press on the client.
Raycast or use proximity to detect nearby eggs.
Send a request to the server to pick up the egg.
Server validates if the player has enough cash.
If valid, deduct cash and give the egg to the player.
Player carries the egg to their base.
When dropped in base, egg is "delivered" (you can expand this later).
✅ Step-by-Step Implementation
🔧 1. Add Cost to Each Egg
In ReplicatedStorage.Eggs, for each egg model:
Add a NumberValue named Cost.
📁 2. Server Script Update (Script in ServerScriptService)
Add this after the moveEgg function:
lua
local Players = game:GetService("Players")
local function giveEggToPlayer(player, eggModel)
local costVal = eggModel:FindFirstChild("Cost")
if not costVal or not costVal:IsA("NumberValue") then return false end
local cost = costVal.Value
local leaderstats = player:FindFirstChild("leaderstats")
local cash = leaderstats and leaderstats:FindFirstChild("Cash")
if not cash or cash.Value < cost then
return false
end
cash.Value -= cost
-- Clone and parent to player's character
local clone = eggModel:Clone()
clone.Parent = player.Character or player.CharacterAdded:Wait()
clone:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 2, 0))
-- Weld to player
local weld = Instance.new("WeldConstraint")
weld.Part0 = clone.PrimaryPart
weld.Part1 = player.Character.HumanoidRootPart
weld.Parent = clone
eggModel:Destroy()
return true
end
-- RemoteEvent for pickup
local PickupEggEvent = Instance.new("RemoteEvent")
PickupEggEvent.Name = "PickupEggEvent"
PickupEggEvent.Parent = ReplicatedStorage
PickupEggEvent.OnServerEvent:Connect(function(player, eggModel)
if eggModel and eggModel.Parent == workspace then
giveEggToPlayer(player, eggModel)
end
end)
User
give me the full scripts
Assistant
Below are the complete, drop-in replacements for your current scripts.
Nothing else in your place needs to change except making sure every egg in
ReplicatedStorage.Eggs has a NumberValue named Cost (and optionally
SpawnChance if you still use weighted spawning).
────────────────────────────────────────
SERVER SCRIPT
(ServerScriptService → “EggConveyorServer” or keep your current script)
lua
User
clone:PivotTo(rotedCF)
Argument 1 missing or nil
Assistant
That’s just a typo in the server script — rotedCF should be rotatedCF.
Replace the single bad line inside the main spawner loop:
lua
-- OLD (wrong):
clone:PivotTo(rotedCF)
-- NEW (fixed):
clone:PivotTo(rotatedCF)
After that change the server script will run without the “Argument 1 missing or nil” error.
📁 3. Local Script Update (LocalScript in StarterPlayerScripts)
Add this after the Cash.Changed connection:
lua
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local PickupEggEvent = ReplicatedStorage:WaitForChild("PickupEggEvent")
local function getEggInSight()
local character = Player.Character or Player.CharacterAdded:Wait()
local root = character:FindFirstChild("HumanoidRootPart")
if not root then return nil end
local ray = Ray.new(root.Position, root.CFrame.LookVector * 10)
local part, pos = workspace:FindPartOnRay(ray)
if part and part.Parent and part.Parent:FindFirstChild("Cost") then
return part.Parent
end
return nil
end
local holdingEgg = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.E then
local egg = getEggInSight()
if egg and not holdingEgg then
PickupEggEvent:FireServer(egg)
holdingEgg = true
end
end
end)
-- Optional: Drop egg on key press (e.g., F)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
local character = Player.Character
if character then
for _, v in ipairs(character:GetChildren()) do
if v:FindFirstChild("Cost") then
v:Destroy()
holdingEgg = false
end
end
end
end
end)
✅ Summary of Features Added
Feature
Status
Press E to pick up egg
✅
Egg must be in front of player
✅
Deducts cash based on egg cost
✅
Prevents pickup if not enough cash
✅
Egg welded to player
✅
Press F to drop egg
✅
🧪 Optional Enhancements
Add a UI prompt when near an egg.
Add egg delivery zone in base to "cash in".
Add egg value multiplier based on rebirths.
Let me know if you want to expand this into a full delivery system or add animations!
--// SERVICES
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--// FOLDERS / EVENTS
local CoreEvent = ReplicatedStorage:WaitForChild("CoreEvent")
local PickupEggEvent = Instance.new("RemoteEvent")
PickupEggEvent.Name = "PickupEggEvent"
PickupEggEvent.Parent = ReplicatedStorage
local conveyor = workspace:WaitForChild("Conveyor")
local waypointsFolder = conveyor:WaitForChild("WayPoints")
local eggsFolder = ReplicatedStorage:WaitForChild("Eggs")
--// CONFIG
local spawnInterval = 3
local moveTime = 1
--// WAYPOINTS
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]
--// CHOOSE RANDOM EGG (weighted)
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
--// SMOOTH TWEEN
local function moveModelSmooth(model, targetCFrame)
local cframeVal = Instance.new("CFrameValue")
cframeVal.Value = model:GetPivot()
cframeVal.Changed:Connect(function(v) model:PivotTo(v) 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
--// MOVE EGG ALONG WAYPOINTS
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))
moveModelSmooth(eggModel, rotatedCF).Completed:Wait()
end
if eggModel and eggModel.Parent then eggModel:Destroy() end
end)()
end
--// BASE LOCKING (unchanged)
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
--// PLAYER ADDED (unchanged)
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)
--// PICKUP REQUEST HANDLER
PickupEggEvent.OnServerEvent:Connect(function(player, eggModel)
if not eggModel or eggModel.Parent ~= workspace then return end
local costVal = eggModel:FindFirstChild("Cost")
if not costVal or not costVal:IsA("NumberValue") then return end
local cost = costVal.Value
local leaderstats = player:FindFirstChild("leaderstats")
local cash = leaderstats and leaderstats:FindFirstChild("Cash")
if not cash or cash.Value < cost then return end
-- Deduct cash
cash.Value -= cost
-- Attach to player
local char = player.Character or player.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local clone = eggModel:Clone()
clone.Parent = char
clone:SetPrimaryPartCFrame(root.CFrame * CFrame.new(0,2,0))
local weld = Instance.new("WeldConstraint")
weld.Part0 = clone.PrimaryPart
weld.Part1 = root
weld.Parent = clone
eggModel:Destroy()
end)
--// MAIN SPAWNER LOOP
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))
clone:PivotTo(rotedCF)
moveEgg(clone)
end
end
task.wait(spawnInterval)
end
────────────────────────────────────────
LOCAL SCRIPT
(StarterPlayer → StarterPlayerScripts → “EggPickupClient”)
lua
--// SERVICES
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--// CONSTANTS
local Player = Players.LocalPlayer
local CoreEvent = ReplicatedStorage:WaitForChild("CoreEvent")
local PickupEggEvent = ReplicatedStorage:WaitForChild("PickupEggEvent")
local CoreGUI = Player:WaitForChild("PlayerGui"):WaitForChild("CoreGUI")
--// UTIL
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
--// WAIT FOR LEADERSTATS
local leaderstats = waitForChildTimeout(Player, "leaderstats", 5)
local Cash = leaderstats and waitForChildTimeout(leaderstats, "Cash", 5)
--// UPDATE UI
if Cash then
Cash.Changed:Connect(function()
CoreGUI.MoneyTextLabel.Text = "$" .. Cash.Value
end)
end
--// RAYCAST FOR EGG IN FRONT
local function getEggInSight()
local character = Player.Character or Player.CharacterAdded:Wait()
local root = character:FindFirstChild("HumanoidRootPart")
if not root then return nil end
local ray = Ray.new(root.Position, root.CFrame.LookVector * 10)
local part = workspace:FindPartOnRay(ray)
if part and part.Parent and part.Parent:FindFirstChild("Cost") then
return part.Parent
end
return nil
end
--// INPUT
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.E then
local egg = getEggInSight()
if egg and egg.Parent == workspace then
PickupEggEvent:FireServer(egg)
end
end
-- Drop egg with F
if input.KeyCode == Enum.KeyCode.F then
local char = Player.Character
if char then
for _, v in ipairs(char:GetChildren()) do
if v:FindFirstChild("Cost") then
v:Destroy()
end
end
end
end
end)
--// BASE LOCK UI (unchanged)
CoreEvent.OnClientEvent:Connect(function(eventtype, Base)
if eventtype == "LockBase" then
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)
Every egg in ReplicatedStorage.Eggs must contain:
• Cost (NumberValue) – how much cash is deducted on pickup
• (Optional) SpawnChance (NumberValue) – for weighted spawning
No other scripts need to be touched.
Press E while looking at an egg to pick it up (if you have enough cash).