Replicated storage:
Folder: Remote Events:
Remote events of the folder:
LevelUp
PerformRitual
RecruitNPC
RecruitSuccess
RitualSuccess
UpdatePlayerData
Folder: Shared Data
ModuleScripts of the folder:
NPCData: local NPCData = {}
[Link] = {
Common = {
Color = [Link](169, 169, 169),
Chance = 70,
DivineMultiplier = 1
},
Uncommon = {
Color = [Link](30, 255, 0),
Chance = 20,
DivineMultiplier = 2
},
Rare = {
Color = [Link](0, 112, 255),
Chance = 7,
DivineMultiplier = 5
},
Epic = {
Color = [Link](163, 53, 238),
Chance = 2.5,
DivineMultiplier = 10
},
Legendary = {
Color = [Link](255, 128, 0),
Chance = 0.45,
DivineMultiplier = 25
},
Mythic = {
Color = [Link](255, 20, 147),
Chance = 0.05,
DivineMultiplier = 100
[Link] = {
-- Common NPCs (70%)
Civilian = {Rarity = "Common", Title = "Civilian"},
Student = {Rarity = "Common", Title = "Student"},
Worker = {Rarity = "Common", Title = "Factory Worker"},
-- Uncommon NPCs (20%)
Teacher = {Rarity = "Uncommon", Title = "School Teacher"},
Nurse = {Rarity = "Uncommon", Title = "Nurse"},
Cashier = {Rarity = "Uncommon", Title = "Store Manager"},
-- Rare NPCs (7%)
Doctor = {Rarity = "Rare", Title = "Doctor"},
Lawyer = {Rarity = "Rare", Title = "Lawyer"},
Engineer = {Rarity = "Rare", Title = "Engineer"},
-- Epic NPCs (2.5%)
Judge = {Rarity = "Epic", Title = "Federal Judge"},
CEO = {Rarity = "Epic", Title = "Corporate CEO"},
General = {Rarity = "Epic", Title = "Army General"},
-- Legendary NPCs (0.45%)
Celebrity = {Rarity = "Legendary", Title = "Famous Celebrity"},
Billionaire = {Rarity = "Legendary", Title = "Tech Billionaire"},
Ambassador = {Rarity = "Legendary", Title = "UN Ambassador"},
-- Mythic NPCs (0.05%)
President = {Rarity = "Mythic", Title = "World President"},
Alien = {Rarity = "Mythic", Title = "Alien Overlord"},
TimeTravel = {Rarity = "Mythic", Title = "Time Traveler"}
function NPCData:GetRandomNPC()
local rand = [Link]() * 100
local cumulative = 0
for rarityName, rarityData in pairs([Link]) do
cumulative = cumulative + [Link]
if rand <= cumulative then
-- Find NPC of this rarity
local possibleNPCs = {}
for npcName, npcData in pairs([Link]) do
if [Link] == rarityName then
[Link](possibleNPCs, {Name = npcName, Data = npcData})
end
end
if #possibleNPCs > 0 then
local chosen = possibleNPCs[[Link](#possibleNPCs)]
return [Link], [Link], rarityData
end
end
end
-- Fallback
return "Civilian", [Link], [Link]
end
return NPCData
Stock system: local StockSystem = {}
local NPCData = require([Link])
[Link] = {}
[Link] = 0
StockSystem.STOCK_REFRESH_INTERVAL = 300 -- 5 minutes in seconds
-- Price multipliers based on rarity
local RARITY_PRICES = {
Common = 75,
Uncommon = 200,
Rare = 500,
Epic = 1500,
Legendary = 5000,
Mythic = 25000
-- Stock slots based on rarity (how many can appear in stock)
local RARITY_STOCK_SLOTS = {
Common = {min = 3, max = 5},
Uncommon = {min = 2, max = 4},
Rare = {min = 1, max = 3},
Epic = {min = 0, max = 2},
Legendary = {min = 0, max = 1},
Mythic = {min = 0, max = 1}
function StockSystem:GenerateStock()
local newStock = {}
local stockId = 1
print("Generating new stock...")
-- Generate stock for each rarity
for rarityName, rarityData in pairs([Link]) do
local slotData = RARITY_STOCK_SLOTS[rarityName]
local numSlots = [Link]([Link], [Link])
-- Get all NPCs of this rarity
local possibleNPCs = {}
for npcName, npcData in pairs([Link]) do
if [Link] == rarityName then
[Link](possibleNPCs, {Name = npcName, Data = npcData})
end
end
-- Add random NPCs of this rarity to stock
for i = 1, numSlots do
if #possibleNPCs > 0 then
local chosenNPC = possibleNPCs[[Link](#possibleNPCs)]
local price = RARITY_PRICES[rarityName] + [Link](-20, 20) --
Small price variation
newStock[stockId] = {
id = stockId,
npcName = [Link],
npcData = [Link],
rarityData = rarityData,
price = price,
quantity = [Link](1, 3) -- Limited quantity
stockId = stockId + 1
end
end
end
[Link] = newStock
[Link] = tick()
print("Stock generated with", #newStock, "items")
return newStock
end
function StockSystem:GetStock()
-- Check if stock needs refresh
if tick() - [Link] >= self.STOCK_REFRESH_INTERVAL then
self:GenerateStock()
end
return [Link], [Link] + self.STOCK_REFRESH_INTERVAL
end
function StockSystem:PurchaseFromStock(stockId)
local item = [Link][stockId]
if not item or [Link] <= 0 then
return false, "Item not available"
end
-- Reduce quantity
[Link] = [Link] - 1
-- Remove if out of stock
if [Link] <= 0 then
[Link][stockId] = nil
end
return true, item
end
function StockSystem:GetTimeUntilRefresh()
local nextRefresh = [Link] + self.STOCK_REFRESH_INTERVAL
return [Link](0, nextRefresh - tick())
end
-- Initialize stock on first load
StockSystem:GenerateStock()
return StockSystem
ServerScriptService:
Folders:
Core
Data
Systems
Whats inside the Systems Folder:
SimpleLeaderboard script: local Players = game:GetService("Players")
local function createLeaderboard(player)
-- Create leaderstats folder
local leaderstats = [Link]("Folder")
[Link] = "leaderstats"
[Link] = player
-- Divine Power stat
local divinePower = [Link]("IntValue")
[Link] = "Divine Power"
[Link] = 300 -- Increased starting amount
[Link] = leaderstats
-- Followers stat
local followers = [Link]("IntValue")
[Link] = "Followers"
[Link] = 0
[Link] = leaderstats
-- Cult Level stat
local level = [Link]("IntValue")
[Link] = "Cult Level"
[Link] = 1
[Link] = leaderstats
print("Leaderboard created for", [Link])
end
-- Create leaderboard when player joins
[Link]:Connect(function(player)
createLeaderboard(player)
end)
-- Handle players already in game
for _, player in pairs(Players:GetPlayers()) do
createLeaderboard(player)
end
StockServerHandler script: local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
-- Wait for or create RemoteEvents
local function getOrCreateRemoteEvent(name)
local remoteEvents = ReplicatedStorage:FindFirstChild("RemoteEvents")
if not remoteEvents then
remoteEvents = [Link]("Folder")
[Link] = "RemoteEvents"
[Link] = ReplicatedStorage
end
local event = remoteEvents:FindFirstChild(name)
if not event then
event = [Link]("RemoteEvent")
[Link] = name
[Link] = remoteEvents
end
return event
end
-- Create necessary remote events
local purchaseEvent = getOrCreateRemoteEvent("PurchaseFromStock")
local updateDataEvent = getOrCreateRemoteEvent("UpdatePlayerData")
local stockUpdateEvent = getOrCreateRemoteEvent("StockUpdated")
-- Load modules
local StockSystem =
require(ReplicatedStorage:WaitForChild("SharedData"):WaitForChild("StockSystem"))
-- Simple player data storage (since we removed DataManager)
local PlayerData = {}
-- Initialize player data
local function initPlayerData(player)
PlayerData[[Link]] = {
DivinePower = 300, -- Increased starting amount for stock-only economy
Followers = {},
Level = 1
-- Send initial data to client
updateDataEvent:FireClient(player, PlayerData[[Link]])
end
-- Handle purchase requests
[Link]:Connect(function(player, stockId)
local playerData = PlayerData[[Link]]
if not playerData then return end
print([Link], "attempting to purchase stock item", stockId)
-- Get stock item info
local stock = StockSystem:GetStock()
local item = stock[stockId]
if not item then
print("Item not found in stock")
return
end
-- Check if player has enough Divine Power
if [Link] < [Link] then
print("Player doesn't have enough Divine Power")
return
end
-- Attempt purchase
local success, result = StockSystem:PurchaseFromStock(stockId)
if success then
-- Deduct Divine Power
[Link] = [Link] - [Link]
-- Add follower to player
local follower = {
Name = [Link],
Title = [Link],
Rarity = [Link],
DivineMultiplier = [Link],
JoinTime = tick(),
Source = "Stock"
[Link]([Link], follower)
-- Update client
updateDataEvent:FireClient(player, playerData)
-- Update leaderboard
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
leaderstats["Divine Power"].Value = [Link]
[Link] = #[Link]
end
print([Link], "successfully purchased", [Link], "for", [Link], "DP")
-- Notify all clients that stock updated
for _, p in pairs(Players:GetPlayers()) do
stockUpdateEvent:FireClient(p)
end
else
print("Purchase failed:", result)
end
end)
-- Handle players joining/leaving
[Link]:Connect(function(player)
initPlayerData(player)
end)
[Link]:Connect(function(player)
PlayerData[[Link]] = nil
end)
-- Initialize existing players
for _, player in pairs(Players:GetPlayers()) do
initPlayerData(player)
end
-- Auto-refresh stock and notify clients
spawn(function()
while true do
wait(300) -- 5 minutes
StockSystem:GenerateStock()
print("Stock refreshed! Notifying all players...")
for _, player in pairs(Players:GetPlayers()) do
stockUpdateEvent:FireClient(player)
end
end
end)
print("Stock Server Handler initialized!")
StarterGUI:
ScreenGUI’S:
CultGUI
StockGUI
LocalScripts of CultGUI:
GUIHandler: print("GUI Script Started!")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local player = [Link]
local gui = [Link]
print("Player found:", [Link])
-- Wait for NPCData to exist (with timeout)
local NPCData = nil
local attempts = 0
while attempts < 10 do
local success, result = pcall(function()
return
require(ReplicatedStorage:WaitForChild("SharedData"):WaitForChild("NPCData"))
end)
if success then
NPCData = result
break
else
print("Waiting for NPCData... attempt", attempts + 1)
wait(1)
attempts = attempts + 1
end
end
if not NPCData then
print("ERROR: Could not load NPCData!")
-- Create fake NPCData for testing
NPCData = {
Rarities = {
Common = {
Color = [Link](169, 169, 169),
DivineMultiplier = 1
end
print("NPCData loaded successfully!")
-- Create MainFrame
local mainFrame = [Link]("Frame")
[Link] = "MainFrame"
[Link] = [Link](0.3, 0, 0.6, 0)
[Link] = [Link](0.35, 0, 0.2, 0)
mainFrame.BackgroundColor3 = [Link](40, 40, 40)
[Link] = 0.2
[Link] = 2
mainFrame.BorderColor3 = [Link](255, 255, 255)
[Link] = gui
print("MainFrame created!")
-- Add rounded corners
local corner = [Link]("UICorner")
[Link] = [Link](0, 10)
[Link] = mainFrame
-- Player data (temporary for testing)
local playerData = {
DivinePower = 300, -- Increased starting amount
Followers = {},
Level = 1
-- Create all GUI elements
local function createGUI()
print("Creating GUI elements...")
-- Title
local title = [Link]("TextLabel")
[Link] = "Title"
[Link] = [Link](1, 0, 0.1, 0)
[Link] = [Link](0, 0, 0, 0)
[Link] = 1
[Link] = "BUILD YOUR CULT"
title.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = mainFrame
print("Title created!")
-- Divine Power Display
local powerDisplay = [Link]("TextLabel")
[Link] = "PowerDisplay"
[Link] = [Link](1, 0, 0.1, 0)
[Link] = [Link](0, 0, 0.1, 0)
[Link] = 1
[Link] = "Divine Power: " .. [Link]
powerDisplay.TextColor3 = [Link](255, 215, 0)
[Link] = true
[Link] = [Link]
[Link] = mainFrame
print("Power display created!")
-- Follower Count
local followerDisplay = [Link]("TextLabel")
[Link] = "FollowerDisplay"
[Link] = [Link](1, 0, 0.1, 0)
[Link] = [Link](0, 0, 0.2, 0)
[Link] = 1
[Link] = "Followers: " .. #[Link]
followerDisplay.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = mainFrame
print("Follower display created!")
-- Stock Info Button
local stockButton = [Link]("TextButton")
[Link] = "StockButton"
[Link] = [Link](0.8, 0, 0.15, 0)
[Link] = [Link](0.1, 0, 0.35, 0)
stockButton.BackgroundColor3 = [Link](0, 150, 255)
[Link] = "VISIT STOCK TRADER"
stockButton.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = mainFrame
print("Stock button created!")
-- Add button corner
local stockCorner = [Link]("UICorner")
[Link] = [Link](0, 5)
[Link] = stockButton
-- Ritual Button
local ritualButton = [Link]("TextButton")
[Link] = "RitualButton"
[Link] = [Link](0.8, 0, 0.15, 0)
[Link] = [Link](0.1, 0, 0.55, 0)
ritualButton.BackgroundColor3 = [Link](128, 0, 128)
[Link] = "PERFORM RITUAL"
ritualButton.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = mainFrame
print("Ritual button created!")
-- Add button corner
local ritualCorner = [Link]("UICorner")
[Link] = [Link](0, 5)
[Link] = ritualButton
-- Followers List (ScrollingFrame)
local followersList = [Link]("ScrollingFrame")
[Link] = "FollowersList"
[Link] = [Link](0.9, 0, 0.2, 0)
[Link] = [Link](0.05, 0, 0.75, 0)
followersList.BackgroundColor3 = [Link](50, 50, 50)
[Link] = 8
[Link] = mainFrame
print("Followers list created!")
-- Stock Button Functionality
stockButton.MouseButton1Click:Connect(function()
print("Directing player to stock trader!")
-- Animation
local tween = TweenService:Create(stockButton, [Link](0.1), {Size =
[Link](0.75, 0, 0.14, 0)})
tween:Play()
[Link]:Connect(function()
TweenService:Create(stockButton, [Link](0.1), {Size = [Link](0.8,
0, 0.15, 0)}):Play()
end)
-- Show direction message
showDirectionPopup()
end)
ritualButton.MouseButton1Click:Connect(function()
print("Ritual button clicked!")
if #[Link] > 0 then
local tween = TweenService:Create(ritualButton, [Link](0.1), {Size =
[Link](0.75, 0, 0.14, 0)})
tween:Play()
[Link]:Connect(function()
TweenService:Create(ritualButton, [Link](0.1), {Size =
[Link](0.8, 0, 0.15, 0)}):Play()
end)
-- Calculate power gain
local powerGain = 0
for _, follower in pairs([Link]) do
powerGain = powerGain + ([Link] * 10)
end
[Link] = [Link] + powerGain
updateGUI()
print("Gained", powerGain, "Divine Power from ritual!")
else
print("No followers to perform ritual!")
end
end)
print("GUI creation complete!")
end
-- Update GUI function
function updateGUI()
print("Updating GUI...")
local powerDisplay = mainFrame:FindFirstChild("PowerDisplay")
local followerDisplay = mainFrame:FindFirstChild("FollowerDisplay")
local stockButton = mainFrame:FindFirstChild("StockButton")
local followersList = mainFrame:FindFirstChild("FollowersList")
if powerDisplay then
[Link] = "Divine Power: " .. [Link]
end
if followerDisplay then
[Link] = "Followers: " .. #[Link]
end
if recruitButton then
local cost = 50 + (#[Link] * 10)
[Link] = "RECRUIT FOLLOWER (" .. cost .. " DP)"
end
-- Update followers list
if followersList then
-- Clear existing
for _, child in pairs(followersList:GetChildren()) do
if child:IsA("Frame") then
child:Destroy()
end
end
-- Add followers with rarity colors
for i, follower in pairs([Link]) do
local followerFrame = [Link]("Frame")
[Link] = [Link](1, -10, 0, 40)
[Link] = [Link](0, 5, 0, (i-1) * 45)
-- Use rarity color if available
if [Link][[Link]] then
followerFrame.BackgroundColor3 =
[Link][[Link]].Color
else
followerFrame.BackgroundColor3 = [Link](100, 100, 100)
end
[Link] = followersList
local nameLabel = [Link]("TextLabel")
[Link] = [Link](1, 0, 1, 0)
[Link] = 1
[Link] = [Link] .. " (" .. [Link] .. ") x" ..
[Link]
nameLabel.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = followerFrame
end
[Link] = [Link](0, 0, 0, #[Link] * 45)
end
end
-- Show direction popup to stock trader
function showDirectionPopup()
local popup = [Link]("Frame")
[Link] = [Link](0.4, 0, 0.3, 0)
[Link] = [Link](0.3, 0, 0.35, 0)
popup.BackgroundColor3 = [Link](0, 150, 255)
[Link] = gui
local corner = [Link]("UICorner")
[Link] = [Link](0, 10)
[Link] = popup
local popupText = [Link]("TextLabel")
[Link] = [Link](1, 0, 1, 0)
[Link] = 1
[Link] = "FIND THE STOCK TRADER!\nRed glowing NPC\nClick to buy followers!"
popupText.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = popup
-- Animate popup
[Link] = [Link](0, 0, 0, 0)
local tween = TweenService:Create(popup, [Link](0.3, [Link]), {Size =
[Link](0.4, 0, 0.3, 0)})
tween:Play()
-- Remove after 3 seconds
spawn(function()
wait(3)
TweenService:Create(popup, [Link](0.3), {Size = [Link](0, 0, 0, 0)}):Play()
wait(0.3)
popup:Destroy()
end)
end
-- Initialize everything
print("Initializing GUI...")
createGUI()
updateGUI()
print("GUI should be visible now!")
LocalScripts of StockGUI:
StockHandler: local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Workspace = game:GetService("Workspace")
local player = [Link]
local gui = [Link]
-- Wait for modules and events
local StockSystem =
require(ReplicatedStorage:WaitForChild("SharedData"):WaitForChild("StockSystem"))
-- Create Remote Events (we'll create these in the server script)
local function waitForRemoteEvent(name)
local remoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
return remoteEvents:WaitForChild(name)
end
-- Player data
local playerData = {DivinePower = 100}
-- GUI State
local stockGUIVisible = false
local stockFrame = nil
-- Create Stock GUI
local function createStockGUI()
-- Main Stock Frame (initially hidden)
stockFrame = [Link]("Frame")
[Link] = "StockFrame"
[Link] = [Link](0.6, 0, 0.8, 0)
[Link] = [Link](0.2, 0, 0.1, 0)
stockFrame.BackgroundColor3 = [Link](20, 20, 20)
[Link] = 0.1
[Link] = 3
stockFrame.BorderColor3 = [Link](255, 215, 0)
[Link] = false
[Link] = gui
-- Add rounded corners
local corner = [Link]("UICorner")
[Link] = [Link](0, 15)
[Link] = stockFrame
-- Title
local title = [Link]("TextLabel")
[Link] = "Title"
[Link] = [Link](1, 0, 0.1, 0)
[Link] = [Link](0, 0, 0, 0)
[Link] = 1
[Link] = "CULT STOCK MARKET"
title.TextColor3 = [Link](255, 215, 0)
[Link] = true
[Link] = [Link]
[Link] = stockFrame
-- Timer Display
local timerDisplay = [Link]("TextLabel")
[Link] = "TimerDisplay"
[Link] = [Link](1, 0, 0.08, 0)
[Link] = [Link](0, 0, 0.1, 0)
[Link] = 1
[Link] = "Next refresh: 5:00"
timerDisplay.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = stockFrame
-- Player DP Display
local dpDisplay = [Link]("TextLabel")
[Link] = "DPDisplay"
[Link] = [Link](1, 0, 0.08, 0)
[Link] = [Link](0, 0, 0.18, 0)
[Link] = 1
[Link] = "Your Divine Power: " .. [Link]
dpDisplay.TextColor3 = [Link](255, 215, 0)
[Link] = true
[Link] = [Link]
[Link] = stockFrame
-- Stock List (ScrollingFrame)
local stockList = [Link]("ScrollingFrame")
[Link] = "StockList"
[Link] = [Link](0.95, 0, 0.6, 0)
[Link] = [Link](0.025, 0, 0.28, 0)
stockList.BackgroundColor3 = [Link](40, 40, 40)
[Link] = 12
[Link] = stockFrame
local listCorner = [Link]("UICorner")
[Link] = [Link](0, 10)
[Link] = stockList
-- Close Button
local closeButton = [Link]("TextButton")
[Link] = "CloseButton"
[Link] = [Link](0.2, 0, 0.08, 0)
[Link] = [Link](0.4, 0, 0.9, 0)
closeButton.BackgroundColor3 = [Link](255, 0, 0)
[Link] = "CLOSE"
closeButton.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = stockFrame
local closeCorner = [Link]("UICorner")
[Link] = [Link](0, 5)
[Link] = closeButton
-- Close button functionality
closeButton.MouseButton1Click:Connect(function()
hideStockGUI()
end)
print("Stock GUI created!")
end
-- Update Stock Display
local function updateStockDisplay()
if not stockFrame or not [Link] then return end
local stockList = stockFrame:FindFirstChild("StockList")
local timerDisplay = stockFrame:FindFirstChild("TimerDisplay")
local dpDisplay = stockFrame:FindFirstChild("DPDisplay")
if not stockList then return end
-- Update timer
if timerDisplay then
local timeLeft = StockSystem:GetTimeUntilRefresh()
local minutes = [Link](timeLeft / 60)
local seconds = [Link](timeLeft % 60)
[Link] = [Link]("Next refresh: %d:%02d", minutes, seconds)
end
-- Update DP display
if dpDisplay then
[Link] = "Your Divine Power: " .. [Link]
end
-- Clear existing stock items
for _, child in pairs(stockList:GetChildren()) do
if child:IsA("Frame") then
child:Destroy()
end
end
-- Get current stock
local stock = StockSystem:GetStock()
local yPos = 0
-- Display stock items
for stockId, item in pairs(stock) do
local itemFrame = [Link]("Frame")
[Link] = "StockItem_" .. stockId
[Link] = [Link](1, -10, 0, 80)
[Link] = [Link](0, 5, 0, yPos)
itemFrame.BackgroundColor3 = [Link]
[Link] = 0.3
[Link] = stockList
local itemCorner = [Link]("UICorner")
[Link] = [Link](0, 8)
[Link] = itemFrame
-- NPC Info
local npcInfo = [Link]("TextLabel")
[Link] = [Link](0.6, 0, 0.6, 0)
[Link] = [Link](0.02, 0, 0.05, 0)
[Link] = 1
[Link] = [Link] .. "\n" .. [Link] .. " (x" ..
[Link] .. ")"
npcInfo.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = [Link]
[Link] = itemFrame
-- Price & Quantity
local priceInfo = [Link]("TextLabel")
[Link] = [Link](0.35, 0, 0.4, 0)
[Link] = [Link](0.02, 0, 0.6, 0)
[Link] = 1
[Link] = "Price: " .. [Link] .. " DP | Qty: " .. [Link]
priceInfo.TextColor3 = [Link](255, 215, 0)
[Link] = true
[Link] = [Link]
[Link] = [Link]
[Link] = itemFrame
-- Buy Button
local buyButton = [Link]("TextButton")
[Link] = [Link](0.25, 0, 0.7, 0)
[Link] = [Link](0.72, 0, 0.15, 0)
buyButton.BackgroundColor3 = [Link](0, 255, 0)
[Link] = "BUY"
buyButton.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = itemFrame
local buyCorner = [Link]("UICorner")
[Link] = [Link](0, 5)
[Link] = buyButton
-- Check if player can afford
if [Link] < [Link] then
buyButton.BackgroundColor3 = [Link](100, 100, 100)
[Link] = "CAN'T AFFORD"
end
-- Buy button functionality
buyButton.MouseButton1Click:Connect(function()
if [Link] >= [Link] then
-- Request purchase (we'll create this remote event)
local purchaseEvent = waitForRemoteEvent("PurchaseFromStock")
purchaseEvent:FireServer(stockId)
end
end)
yPos = yPos + 85
end
-- Update canvas size
[Link] = [Link](0, 0, 0, yPos)
end
-- Show Stock GUI
function showStockGUI()
if stockFrame then
[Link] = true
stockGUIVisible = true
-- Animate entrance
[Link] = [Link](0, 0, 0, 0)
[Link] = [Link](0.5, 0, 0.5, 0)
local tween = TweenService:Create(stockFrame, [Link](0.4,
[Link]), {
Size = [Link](0.6, 0, 0.8, 0),
Position = [Link](0.2, 0, 0.1, 0)
})
tween:Play()
updateStockDisplay()
-- Start updating timer
spawn(function()
while stockGUIVisible do
wait(1)
updateStockDisplay()
end
end)
end
end
-- Hide Stock GUI
function hideStockGUI()
if stockFrame then
stockGUIVisible = false
local tween = TweenService:Create(stockFrame, [Link](0.3), {
Size = [Link](0, 0, 0, 0),
Position = [Link](0.5, 0, 0.5, 0)
})
tween:Play()
[Link]:Connect(function()
[Link] = false
end)
end
end
-- Handle NPC Click
local function setupNPCClick()
local stockNPC = Workspace:WaitForChild("StockNPCPart")
local clickDetector = stockNPC:WaitForChild("ClickDetector")
[Link]:Connect(function()
print("Stock NPC clicked!")
showStockGUI()
end)
end
-- Handle player data updates
local function handleDataUpdate(newData)
playerData = newData
if stockGUIVisible then
updateStockDisplay()
end
end
-- Initialize
createStockGUI()
setupNPCClick()
-- Connect to data updates (from main GUI)
local updateDataEvent = [Link]:WaitForChild("UpdatePlayerData")
[Link]:Connect(handleDataUpdate)