Tower Buyer Script – Gnome Code, Tower Shop & Hidden Towers 0 Key System

Tower Buyer Script – Gnome Code, Tower Shop & Hidden Towers

Universal • 6 hours ago • 0 views

Description

Tower Buyer is a universal Roblox script designed for tower defense games that use the Gnome Code system. It allows players to purchase towers through the in-game Tower Shop, including certain hidden or free towers when supported by the game.

Key Features

  • Tower Buyer: Purchase towers through the Tower Shop
  • Gnome Code Support: Designed for compatible tower defense games using Gnome Code
  • Hidden Tower Purchases: May allow access to hidden towers listed at zero cost when supported
  • Tower Shop Compatibility: Looks for the required tower shop system in supported games
  • Currency Display: Shows a star count that may represent the player’s available currency
  • Direct Execute: Supports direct execution
Universal
Game Page
Universal
Roblox
Views 0+
Likes 0
Dislikes 0
Posted 6 hours ago
Updated 6 hours ago
Key System Yes
Mobile Supported

Script Preview

210 lines • 6.1 KB
-- 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: 226152133" .. 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: 226152133" .. 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 Use This Script

1

Open Your Executor

Launch a supported executor and attach it to a running Roblox session.

2

Copy the Script

Click the Copy button above. The full loadstring is placed on your clipboard instantly.

3

Paste & Execute

Paste it into the executor and hit Execute. The hub window opens inside the game.

Compatible Executors

Comments

0
Join the discussion about this script.

No comments yet. Be the first to comment!