
Universal Script – Tower Buyer (Gnome Code)
-- Tower Buy UI: Type a tower name and buy it if you have enough stars
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local function findRemote(name)
for _, descendant in ipairs(ReplicatedStorage:GetDescendants()) do
if descendant:IsA("RemoteFunction") or descendant:IsA("RemoteEvent") then
if descendant.Name == name then
return descendant
end
end
end
return nil
end
local towers = require(ReplicatedStorage:WaitForChild("TowerShop"))
local getDataFunc = findRemote("GetData")
local interactItemFunc = findRemote("InteractItem")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- ===== Build the UI =====
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "TowerBuyGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = playerGui
-- Main small frame (top-right corner)
local frame = Instance.new("Frame")
frame.Name = "Main"
frame.Size = UDim2.new(0, 240, 0, 120)
frame.Position = UDim2.new(1, -260, 0, 20)
frame.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
frame.BorderSizePixel = 0
frame.Parent = screenGui
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 8)
corner.Parent = frame
-- Title
local title = Instance.new("TextLabel")
title.Name = "Title"
title.Size = UDim2.new(1, -20, 0, 24)
title.Position = UDim2.new(0, 10, 0, 8)
title.BackgroundTransparency = 1
title.Font = Enum.Font.GothamBold
title.TextSize = 14
title.TextColor3 = Color3.fromRGB(255, 215, 0)
title.TextXAlignment = Enum.TextXAlignment.Left
title.Text = "Buy Tower"
title.Parent = frame
-- Stars display
local starsLabel = Instance.new("TextLabel")
starsLabel.Name = "Stars"
starsLabel.Size = UDim2.new(1, -20, 0, 18)
starsLabel.Position = UDim2.new(0, 10, 0, 32)
starsLabel.BackgroundTransparency = 1
starsLabel.Font = Enum.Font.Gotham
starsLabel.TextSize = 13
starsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
starsLabel.TextXAlignment = Enum.TextXAlignment.Left
starsLabel.Text = "Stars: Loading..."
starsLabel.Parent = frame
-- TextBox for tower name
local textBox = Instance.new("TextBox")
textBox.Name = "TowerInput"
textBox.Size = UDim2.new(1, -20, 0, 28)
textBox.Position = UDim2.new(0, 10, 0, 54)
textBox.BackgroundColor3 = Color3.fromRGB(50, 50, 55)
textBox.BorderSizePixel = 0
textBox.Font = Enum.Font.Gotham
textBox.TextSize = 13
textBox.TextColor3 = Color3.fromRGB(255, 255, 255)
textBox.PlaceholderText = "Enter tower name..."
textBox.Text = ""
textBox.Parent = frame
local textBoxCorner = Instance.new("UICorner")
textBoxCorner.CornerRadius = UDim.new(0, 4)
textBoxCorner.Parent = textBox
-- Buy button
local buyButton = Instance.new("TextButton")
buyButton.Name = "Buy"
buyButton.Size = UDim2.new(1, -20, 0, 28)
buyButton.Position = UDim2.new(0, 10, 0, 88)
buyButton.BackgroundColor3 = Color3.fromRGB(60, 140, 60)
buyButton.BorderSizePixel = 0
buyButton.Font = Enum.Font.GothamBold
buyButton.TextSize = 13
buyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
buyButton.Text = "Buy"
buyButton.Parent = frame
local buyCorner = Instance.new("UICorner")
buyCorner.CornerRadius = UDim.new(0, 4)
buyCorner.Parent = buyButton
-- Status / feedback label
local statusLabel = Instance.new("TextLabel")
statusLabel.Name = "Status"
statusLabel.Size = UDim2.new(1, -20, 0, 16)
statusLabel.Position = UDim2.new(0, 10, 1, -20)
statusLabel.BackgroundTransparency = 1
statusLabel.Font = Enum.Font.Gotham
statusLabel.TextSize = 11
statusLabel.TextColor3 = Color3.fromRGB(180, 180, 180)
statusLabel.TextXAlignment = Enum.TextXAlignment.Left
statusLabel.Text = ""
statusLabel.Parent = frame
-- Toggle button (minimize/maximize)
local toggleButton = Instance.new("TextButton")
toggleButton.Name = "Toggle"
toggleButton.Size = UDim2.new(0, 80, 0, 24)
toggleButton.Position = UDim2.new(1, -90, 0, 20)
toggleButton.BackgroundColor3 = Color3.fromRGB(40, 120, 200)
toggleButton.BorderSizePixel = 0
toggleButton.Font = Enum.Font.GothamBold
toggleButton.TextSize = 12
toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
toggleButton.Text = "Tower Shop"
toggleButton.Visible = false
toggleButton.Parent = screenGui
local toggleCorner = Instance.new("UICorner")
toggleCorner.CornerRadius = UDim.new(0, 4)
toggleCorner.Parent = toggleButton
-- ===== Logic =====
local function refreshStars()
if not getDataFunc then return nil end
local data = getDataFunc:InvokeServer()
if data then
starsLabel.Text = "Stars: \226\152\133" .. tostring(data.Stars)
return data
end
return nil
end
local function setStatus(text, color)
statusLabel.Text = text
statusLabel.TextColor3 = color or Color3.fromRGB(180, 180, 180)
end
local function buyTower()
if not interactItemFunc then
setStatus("InteractItem remote not found!", Color3.fromRGB(255, 100, 100))
return
end
local towerName = textBox.Text
if towerName == "" then
setStatus("Please enter a tower name.", Color3.fromRGB(255, 100, 100))
return
end
-- Check if the tower exists in the shop
local towerData = towers[towerName]
if not towerData then
setStatus("Tower '" .. towerName .. "' not found.", Color3.fromRGB(255, 100, 100))
return
end
-- Get player data to check stars
if not getDataFunc then
setStatus("GetData remote not found!", Color3.fromRGB(255, 100, 100))
return
end
local playerData = getDataFunc:InvokeServer()
if not playerData then
setStatus("Could not fetch player data.", Color3.fromRGB(255, 100, 100))
return
end
-- Check if already owned
if table.find(playerData.OwnedTowers, towerName) then
setStatus("You already own this tower.", Color3.fromRGB(255, 200, 0))
return
end
-- Attempt purchase via InteractItem (stars check skipped)
local result = interactItemFunc:InvokeServer(towerName)
if result then
starsLabel.Text = "Stars: \226\152\133" .. tostring(result.Stars)
setStatus("Successfully bought " .. towerName .. "!", Color3.fromRGB(100, 255, 100))
textBox.Text = ""
else
setStatus("Purchase failed.", Color3.fromRGB(255, 100, 100))
end
end
-- Wire up events
buyButton.Activated:Connect(buyTower)
toggleButton.Activated:Connect(function()
frame.Visible = true
toggleButton.Visible = false
refreshStars()
end)
-- Initialize
refreshStars()
print("TowerBuyGui loaded successfully")sfully")How to Execute Universal Script – Tower Buyer (Gnome Code)
Step 1: Copy Code: Click the Copy Code button in the viewer above to grab the clean Lua loadstring.
Step 2: Launch Executor: Open a compatible, unpatched executor. If you need one, check our Roblox Executors Directory.
Step 3: Join Experience: Launch Roblox and join Universal Script.
Step 4: Attach & Run: Attach/inject your executor into the Roblox process, paste the code into the script tab, and press Execute.
Created By
View Author ProfileFeatures & Information
Script Changelog (2)
Community Comments (0)
No comments yet for this script.
Frequently Asked Questions
How do I execute Universal Script – Tower Buyer (Gnome Code) in Roblox?
To run Universal Script – Tower Buyer (Gnome Code), copy the Lua loadstring from the code viewer above, launch Roblox and join Universal Script, attach a working executor (such as Potassium, Solara, or Delta from our Executors directory), paste the code into your executor console, and click Execute.
Is Universal Script – Tower Buyer (Gnome Code) keyless or does it require an access key?
Universal Script – Tower Buyer (Gnome Code) requires an access key. You can retrieve the official key directly using the Get Script Key link provided above.
Is Universal Script – Tower Buyer (Gnome Code) currently safe and working?
This script is active and operational. Always test scripts using a secondary (alt) Roblox account to safeguard your main profile against anti-cheat bans.


![Ez Hub [Open Source] [150+ games] - Verified script for Universal Script](https://media.kocakz.me/b74a9ac15370ba766b2fa9531f17c9dad2c0befb2b951693ae723e4c7d2c3fb6.webp)

![[KEYLESS] Moondiety Script | 20+ supported Games - Verified script for Universal Script](https://media.kocakz.me/6834c33a36c9fbe66afae4c6754c2b80386ce636b2f972464a95866f4b6a42eb.webp)

