Kalananti Holiday Program - Ranch Factory Tycoon Game

Source Code

FeedScript
-- VARIABLES --
local Product = nil -- game.ServerStorage.Product.Egg
local ProductFolder = nil -- game.Workspace.Box.EggBox

local FoodBox = script.Parent
local Food = FoodBox.Food
local ProximityPrompt = nil -- FoodBox.ProximityPrompt

-- FUNCTIONS --
function Feeding()
	ProximityPrompt.Enabled = false
	Food.Transparency = 0

	wait(3)

	local NewProduct = Product:Clone()
	NewProduct.Parent = ProductFolder

	ProximityPrompt.Enabled = true
	Food.Transparency = 1
end

-- EVENTS --
ProximityPrompt.Triggered:Connect(Feeding)
Leaderstats
-- SERVICES --
local Players = game:GetService("Players")

-- FUNCTIONS --
function PlayerAdded(Player)
	local Leaderstats = Instance.new("Folder", Player)
	Leaderstats.Name = "leaderstats"

	local Money = Instance.new("IntValue", Leaderstats)
	Money.Name = "Money"
	Money.Value = 0
end

-- EVENTS --
Players.PlayerAdded:Connect(PlayerAdded)
PickUpScript
-- VARIABLES --
local Box = nil -- game.Workspace.Box.WoolBox

local PickUpArea = script.Parent
local Price = nil -- PickUpArea.Price

local PickedUp = false

-- FUNCTIONS --
function PickUp(HitPart)
	local Player = game.Players:GetPlayerFromCharacter(HitPart.Parent)

	if Player then
		local Leaderstats = Player:WaitForChild("leaderstats")
		local Money = Leaderstats:WaitForChild("Money")

		if PickedUp == false then
			PickedUp = true
			local BoxChildren = Box:GetChildren()

			Money.Value += Price.Value * #BoxChildren
			Box:ClearAllChildren()

			PickedUp = false
		end
	end
end

-- EVENTS --
PickUpArea.Touched:Connect(PickUp)
PurchaseScript
-- VARIABLES --
local BuildingFolder = nil -- game.ServerStorage.Building
local Building = nil -- BuildingFolder.ChickenCoop

local PurchaseButton = script.Parent
local PurchaseModel = PurchaseButton.Parent
local Price = PurchaseButton.Price

local Purchased = false

-- FUNCTIONS --
function PurchaseBuilding(HitPart)
	local Player = game.Players:GetPlayerFromCharacter(HitPart.Parent)

	if Player then
		local Leaderstats = Player:WaitForChild("leaderstats")
		local Money = Leaderstats:WaitForChild("Money")
		
		if Money.Value >= Price.Value and Purchased == false then
			Purchased = true
			Money.Value -= Price.Value

			local NewBuilding = Building:Clone()
			NewBuilding.Parent = game.Workspace

			PurchaseModel:Destroy()
		end
	end
end

-- EVENTS --
PurchaseButton.Touched:Connect(PurchaseBuilding)

Starter Project
Roblox - Ranch Factory Tycoon Starter Project.rbxl (701.5 KB)