I'll help you create a complete Roblox Studio system for knowledge management with UI, leaderboard, and selling functionality.
1. Leaderboard Setup (ServerScriptService)
Create a script in ServerScriptService called "KnowledgeSystem":
-- ServerScriptService.KnowledgeSystem
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local knowledgeDataStore = DataStoreService:GetDataStore("KnowledgeData")
local function setupLeaderboard(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local knowledge = Instance.new("IntValue")
knowledge.Name = "Knowledge"
knowledge.Value = 0
knowledge.Parent = leaderstats
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = leaderstats
-- Load data
local success, data = pcall(function()
return knowledgeDataStore:GetAsync(player.UserId)
end)
if success and data then
knowledge.Value = data.knowledge or 0
coins.Value = data.coins or 0
end
-- Save data when player leaves
player.CharacterRemoving:Connect(function()
local saveData = {
knowledge = knowledge.Value,
coins = coins.Value
}
pcall(function()
knowledgeDataStore:SetAsync(player.UserId, saveData)
end)
end)
end
Players.PlayerAdded:Connect(setupLeaderboard)
2. UI Button Setup (StarterGui)
Create a ScreenGui in StarterGui called "KnowledgeUI", then add these elements:
KnowledgeButton (TextButton)
- Size: {0.2, 0}, {0.1, 0}
- Position: {0.4, 0}, {0.8, 0}
- Text: "Gain Knowledge (+5)"
- BackgroundColor3: [0, 170, 255]
SellButton (TextButton)
- Size: {0.2, 0}, {0.1, 0}
- Position: {0.4, 0}, {0.65, 0}
- Text: "Sell Knowledge"
- BackgroundColor3: [0, 255, 127]
KnowledgeDisplay (TextLabel)
- Size: {0.3, 0}, {0.1, 0}
- Position: {0.35, 0}, {0.1, 0}
- Text: "Knowledge: 0/100"
- BackgroundTransparency: 1
- TextScaled: true
3. LocalScript (inside KnowledgeButton)
-- StarterGui.KnowledgeUI.KnowledgeButton.LocalScript
local button = script.Parent
local player = game.Players.LocalPlayer
local knowledgeSound = script:WaitForChild("KnowledgeSound")
local maxKnowledge = 100
local function updateDisplay()
local knowledge = player.leaderstats.Knowledge.Value
local display = script.Parent.Parent.KnowledgeDisplay
display.Text = string.format("Knowledge: %d/%d", knowledge, maxKnowledge)
end
button.MouseButton1Click:Connect(function()
local currentKnowledge = player.leaderstats.Knowledge.Value
if currentKnowledge < maxKnowledge then
game.ReplicatedStorage.GainKnowledge:FireServer()
knowledgeSound:Play()
updateDisplay()
end
end)
-- Update display when knowledge changes
player.leaderstats.Knowledge.Changed:Connect(updateDisplay)
updateDisplay()
4. LocalScript (inside SellButton)
-- StarterGui.KnowledgeUI.SellButton.LocalScript
local button = script.Parent
local player = game.Players.LocalPlayer
local sellSound = script:WaitForChild("SellSound")
local function updateDisplay()
local knowledge = player.leaderstats.Knowledge.Value
local display = script.Parent.Parent.KnowledgeDisplay
display.Text = string.format("Knowledge: %d/100", knowledge)
end
button.MouseButton1Click:Connect(function()
local currentKnowledge = player.leaderstats.Knowledge.Value
if currentKnowledge >= 100 then
game.ReplicatedStorage.SellKnowledge:FireServer()
sellSound:Play()
updateDisplay()
end
end)
5. RemoteEvents (ReplicatedStorage)
Create these in ReplicatedStorage:
- GainKnowledge (RemoteEvent)
- SellKnowledge (RemoteEvent)
6. Server Script (ServerScriptService)
Create another script in ServerScriptService called "KnowledgeHandlers":
-- ServerScriptService.KnowledgeHandlers
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local maxKnowledge = 100
local function gainKnowledge(player)
local knowledge = player.leaderstats.Knowledge
if knowledge.Value < maxKnowledge then
knowledge.Value = math.min(knowledge.Value + 5, maxKnowledge)
end
end
local function sellKnowledge(player)
local knowledge = player.leaderstats.Knowledge
local coins = player.leaderstats.Coins
if knowledge.Value >= 100 then
local sellAmount = math.floor(knowledge.Value / 100) * 100
local coinGain = math.round((sellAmount / 100) * 10)
knowledge.Value = knowledge.Value - sellAmount
coins.Value = coins.Value + coinGain
end
end
ReplicatedStorage.GainKnowledge.OnServerEvent:Connect(gainKnowledge)
ReplicatedStorage.SellKnowledge.OnServerEvent:Connect(sellKnowledge)
7. Sound Setup
For Knowledge Sound:
- SoundId: rbxassetid://160432334 (coin sound)
- Volume: 0.5
- Place this inside the KnowledgeButton as "KnowledgeSound"
For Sell Sound:
- SoundId: rbxassetid://138186576 (cash register sound)
- Volume: 0.5
- Place this inside the SellButton as "SellSound"
8. Additional Features (Optional)
To make the UI more polished, add this script to KnowledgeUI:
-- StarterGui.KnowledgeUI.Script
local player = game.Players.LocalPlayer
local knowledgeDisplay = script.Parent.KnowledgeDisplay
local function updateDisplay()
local knowledge = player.leaderstats.Knowledge.Value
knowledgeDisplay.Text = string.format("Knowledge: %d/100", knowledge)
-- Change color based on how full it is
local percentage = knowledge / 100
if percentage >= 1 then
knowledgeDisplay.TextColor3 = Color3.new(0, 1, 0) -- Green when full
elseif percentage >= 0.5 then
knowledgeDisplay.TextColor3 = Color3.new(1, 1, 0) -- Yellow when half
else
knowledgeDisplay.TextColor3 = Color3.new(1, 1, 1) -- White when low
end
end
player.leaderstats.Knowledge.Changed:Connect(updateDisplay)
updateDisplay()
Usage Instructions:
- Install all scripts in their respective locations
- Test in Studio by pressing F5
- Click the blue button to gain knowledge (max 100)
- Click the green button to sell knowledge in batches of 100
- Check the leaderboard to see your knowledge and coins
The system includes:
- ✅ Knowledge cap of 100
- ✅ +5 knowledge per click
- ✅ 100 knowledge = 10 coins conversion
- ✅ Rounded to nearest whole number
- ✅ Sound effects for both actions
- ✅ Data persistence (saves when you leave)
- ✅ Visual feedback