Description

This script has simple interface and includes the auto purchase and silent aaim functions. but if you see nothing on the script then click arrow on left top corner and then select menu.

Features

  • + Auto purchase everything
  • + Auto upgrade pumps
  • + Purchase selected objects
  • + Toggle Silent aim
  • + Toggle autokill

Script

Add Xeno Scripts as a preferred source
local Lib = loadstring(game:HttpGet("https://raw.githubusercontent.com/laagginq/ui-libraries/main/coastified/src.lua"))()
local Window = Lib:Window('Medieval War Tycoon', "ScriptzStudios", Enum.KeyCode.RightShift)
local TycoonTab = Window:Tab("Tycoon")
local WeaponsTab = Window:Tab('Weapons')

local runService = game:GetService('RunService')

_G.Selected = 'pump'
_G.SelectedAutoPurchase = false
_G.SilentAim = false
_G.AutoUpgrade = false
_G.AutoPurchase = false
_G.AutoPurchasePump = false
_G.AutoKillPlayers = false
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")

local function promptTextInput(config)
	config = config or {}

	-- Config defaults
	local title        = config.Title       or "Enter Text"
	local placeholder  = config.Placeholder or "Type here..."
	local maxLength    = config.MaxLength   or 100
	local width        = config.Width       or UDim2.new(0, 340, 0, 130)
	local position     = config.Position    or UDim2.new(0.5, 0, 0.5, 0)

	-- BindableEvent lets us yield until FocusLost fires
	local finished = Instance.new("BindableEvent")
	local result = ""

	-- ScreenGui
	local screenGui = Instance.new("ScreenGui")
	screenGui.Name = "TextInputGui"
	screenGui.ResetOnSpawn = false
	screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
	screenGui.Parent = PlayerGui

	-- Backdrop (darkened overlay, clicking it also dismisses)
	local backdrop = Instance.new("TextButton")
	backdrop.Name = "Backdrop"
	backdrop.Size = UDim2.new(1, 0, 1, 0)
	backdrop.Position = UDim2.new(0, 0, 0, 0)
	backdrop.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
	backdrop.BackgroundTransparency = 0.5
	backdrop.BorderSizePixel = 0
	backdrop.Text = ""
	backdrop.ZIndex = 1
	backdrop.Parent = screenGui

	-- Main frame
	local frame = Instance.new("Frame")
	frame.Name = "InputFrame"
	frame.Size = width
	frame.Position = position
	frame.AnchorPoint = Vector2.new(0.5, 0.5)
	frame.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
	frame.BorderSizePixel = 0
	frame.ZIndex = 2
	frame.Parent = screenGui

	-- Rounded corners on the frame
	local corner = Instance.new("UICorner")
	corner.CornerRadius = UDim.new(0, 10)
	corner.Parent = frame

	-- Drop shadow effect (decorative frame behind)
	local shadow = Instance.new("Frame")
	shadow.Size = UDim2.new(1, 6, 1, 6)
	shadow.Position = UDim2.new(0, -3, 0, 3)
	shadow.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
	shadow.BackgroundTransparency = 0.6
	shadow.BorderSizePixel = 0
	shadow.ZIndex = 1
	shadow.Parent = frame
	Instance.new("UICorner", shadow).CornerRadius = UDim.new(0, 10)

	-- Title label
	local titleLabel = Instance.new("TextLabel")
	titleLabel.Name = "Title"
	titleLabel.Size = UDim2.new(1, -20, 0, 36)
	titleLabel.Position = UDim2.new(0, 10, 0, 6)
	titleLabel.BackgroundTransparency = 1
	titleLabel.Font = Enum.Font.GothamBold
	titleLabel.Text = title
	titleLabel.TextColor3 = Color3.fromRGB(230, 230, 230)
	titleLabel.TextSize = 16
	titleLabel.TextXAlignment = Enum.TextXAlignment.Left
	titleLabel.ZIndex = 3
	titleLabel.Parent = frame

	-- TextBox
	local textBox = Instance.new("TextBox")
	textBox.Name = "InputBox"
	textBox.Size = UDim2.new(1, -20, 0, 46)
	textBox.Position = UDim2.new(0, 10, 0, 48)
	textBox.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
	textBox.BorderSizePixel = 0
	textBox.Font = Enum.Font.Gotham
	textBox.Text = ""
	textBox.PlaceholderText = placeholder
	textBox.PlaceholderColor3 = Color3.fromRGB(100, 100, 110)
	textBox.TextColor3 = Color3.fromRGB(240, 240, 240)
	textBox.TextSize = 15
	textBox.ClearTextOnFocus = false
	textBox.MaxVisibleGraphemes = maxLength
	textBox.ZIndex = 3
	textBox.Parent = frame
	Instance.new("UICorner", textBox).CornerRadius = UDim.new(0, 6)

	-- Hint label
	local hint = Instance.new("TextLabel")
	hint.Size = UDim2.new(1, -20, 0, 20)
	hint.Position = UDim2.new(0, 10, 1, -26)
	hint.BackgroundTransparency = 1
	hint.Font = Enum.Font.Gotham
	hint.Text = "Press Enter or click away to confirm"
	hint.TextColor3 = Color3.fromRGB(120, 120, 130)
	hint.TextSize = 11
	hint.TextXAlignment = Enum.TextXAlignment.Left
	hint.ZIndex = 3
	hint.Parent = frame

	-- Helper: tear down and return result
	local dismissed = false
	local function dismiss()
		if dismissed then return end
		dismissed = true
		result = textBox.Text
		screenGui:Destroy()
		finished:Fire()
	end

	-- Clicking the backdrop dismisses
	backdrop.MouseButton1Click:Connect(dismiss)

	-- FocusLost fires when player clicks away OR presses Enter
	textBox.FocusLost:Connect(function(enterPressed)
		dismiss()
	end)

	-- Auto-focus the textbox as soon as the GUI appears
	task.defer(function()
		textBox:CaptureFocus()
	end)

	-- Yield until dismiss() fires
	finished.Event:Wait()
	finished:Destroy()

	return result
end
local function containsPump(str, str2)
    return str:lower():find(str2, 1, true) ~= nil
end

local function returnNFS(string)
    local result = string.Text:gsub("%D", "")
    return result
end

local function getPlayerMoney()
        local playerMoney = game:GetService("Players").LocalPlayer.PlayerGui.zHUD.Holder.Left.StatsPanel.Cash
        if not playerMoney then warn('Playermoney not found..') return end
        local playerMoney = returnNFS(playerMoney)
        return tonumber(playerMoney);
end


local function purchaseItem(item)
    local remote = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("Purchase")
    remote:InvokeServer(item)
end

local function autopurchasePumps(toggle)
    _G.AutoPurchasePump = toggle
    if not _G.AutoPurchasePump then return end
    while _G.AutoPurchasePump do
        local objectFolder = game.workspace.ClientTycoon
        for i, v in pairs(objectFolder:GetChildren()) do
            local result;
            local name = v.Name
            result = containsPump(name, 'pump')
            if result then
                -- check price of pump compared to player
                local price = v:FindFirstChild('Cost').Value
                if not price then
                    warn('Price not found')
                    continue
                end

                local canBuy = false
                local playerMoney = getPlayerMoney()
                if not playerMoney then warn('Player money not found..') return end
                if tonumber(playerMoney) >= tonumber(price) then
                    canBuy = true
                end

                if canBuy then
                    purchaseItem(v.Name)
                end
            end
        end
    end
end

local function autopurchaseEverything(toggle)
    _G.AutoPurchase = toggle
    if not _G.AutoPurchase then return end
    while _G.AutoPurchase do
        -- loop through folder, checking values; buying what can
        local clientTycoon = game.workspace.ClientTycoon
        local playerMoney = getPlayerMoney() -- reset this value every time the loop is ran

        for i, v in pairs(clientTycoon:GetChildren()) do
            local authenticated = false
            local cost = v:FindFirstChild('Cost')
            if not cost then 
                warn('Cost not found..') 
            else
                authenticated = true
            end

            if v.Name == 'Drop' then
                authenticated = false
            end

            if authenticated then

                if cost.Value == 0 then continue end
                -- compare to playerMoney
                playerMoney = getPlayerMoney()

                if not playerMoney then warn('pln not found..') continue end
                local canBuy = false

                if playerMoney >= cost.Value then
                    canBuy = true
                end

                if canBuy then
                    purchaseItem(v.Name)
                    print('Request sent for .. ' .. v.Name)
                end
            end
        end
    end
end

local function findClosestPlayerToMouse()
    local localPlayer = game.Players.LocalPlayer
    local myChar = localPlayer.Character
    local myRoot = myChar:FindFirstChild('HumanoidRootPart')
    local mouse = localPlayer:GetMouse()
    local hit = mouse.Hit.Position

    local closestPlayer;
    local closestDistance = math.huge

    -- loop through
    local players = game:GetService('Players')

    for i, player in players:GetChildren() do
        if player == localPlayer then continue end

        local character = player.Character
        if not character then continue end

        local root = character:FindFirstChild('HumanoidRootPart')

        if not root then continue end
        
        distance = (hit - root.Position).Magnitude
        if distance < closestDistance then
            closestDistance = distance
            closestPlayer = player
        end
    end

    if not closestPlayer then
        warn('Closest player NIL')
    end
    return closestPlayer
end

local function findClosestPlayerToChar()
    local closestPlayer;
    local closestDistance = math.huge;
    local player = game.Players.LocalPlayer
    local character = player.Character
    local myRoot = character:FindFirstChild('HumanoidRootPart')
    if not character or not myRoot then
        warn('Character/Root not found..')
        return 
    end

    local allPlayers = game.Players
    for i, plr in pairs(allPlayers:GetChildren()) do
        if plr == player then continue end
        local vChar = plr.Character
        if not vChar then return end
        local vRoot = vChar:FindFirstChild('HumanoidRootPart')
        if not vRoot then return end
        local targetHum = vChar:FindFirstChild('Humanoid')
        if not targetHum then return end
        if not (targetHum.Health > 0) then return end
        local distance = (vRoot.Position - myRoot.Position).Magnitude

        -- compare
        if distance < closestDistance then
            closestDistance = distance
            closestPlayer = plr
        end
    end
    return closestPlayer;
end

local function onCrossbow()
    if not _G.SilentAim then return end -- only for silent aim, killAll later
    local closestPlayer = findClosestPlayerToMouse()
    if not closestPlayer then
        warn('No closest player detected..')
        return
    end
    local mouse = game.Players.LocalPlayer:GetMouse()
    local hitPosition = mouse.Hit.Position
    -- fire to closest player
    local args = {
        "Fire",
         closestPlayer.Character:FindFirstChild('HumanoidRootPart').Position,
        closestPlayer.Character:FindFirstChild('HumanoidRootPart'),
        false,
        "HumanoidRootPart"
    }
    game:GetService("Players").LocalPlayer.Character:WaitForChild("Crossbow"):WaitForChild("RemoteEvent"):FireServer(unpack(args))

end

local function crossbowSilentAimToggle(toggle)
    _G.SilentAim = toggle
    if not _G.SilentAim then return end
    -- catch fire
    local crossbow = game:GetService("Players").LocalPlayer.Backpack:FindFirstChild('Crossbow') or game:GetService('Players').LocalPlayer.Character:FindFirstChild('Crossbow')

    if not crossbow then
        warn('Crossbow not found..')
        return 
    end

    -- catch fire event
    crossbow.Activated:Connect(onCrossbow)
end

_G.CurrentTarget = nil;
_G.ShouldTarget = false;

local function keepOnPlayer()
    local myPlayer = game.Players.LocalPlayer
    local myChar = myPlayer.Character
    runService.Heartbeat:Connect(function()
        if _G.ShouldTarget then
            local target = _G.CurrentTarget
            if not target then return end
            local myRoot = myChar:FindFirstChild('HumanoidRootPart')
            if not myRoot then return end
            local character = target.Character
            if not character then return end
            local root = character:FindFirstChild('HumanoidRootPart')
            if not root then return end
            -- teleport above
            local rootPosition = root.Position

            local teleportPosition = Vector3.new(rootPosition.X, rootPosition.Y + 30, rootPosition.Z)
            myRoot.Position = teleportPosition
        end
    end)
end

local function autoKillPlayers(toggle)
    _G.AutoKillPlayers = toggle
    if not _G.AutoKillPlayers then return end
    while _G.AutoKillPlayers do
        task.wait(1)
        local player = game.Players.LocalPlayer
        local mouse = player:GetMouse()
        -- find closestPlayer
        local closestPlayer = findClosestPlayerToChar()
        if not closestPlayer then
         warn('Closest-Player not detected..')
        end

        -- kill player,
        if closestPlayer and _G.AutoKillPlayers then
            while closestPlayer.Character.Humanoid.Health > 0  and _G.AutoKillPlayers do
                -- teleport on top of player in new taks
                _G.ShouldTarget = true;

                -- shoot player
                local hit = mouse.Hit.Position

                    local args = {
                    "Fire",
                    hit,
                    closestPlayer.Character:FindFirstChild('HumanoidRootPart'),
                    false,
                    "HumanoidRootPart"
                }
                game:GetService("Players").LocalPlayer.Character:WaitForChild("Crossbow"):WaitForChild("RemoteEvent"):FireServer(unpack(args))
                task.wait(0.1)
                if closestPlayer.Character.Humanoid.Health == 0 then
                    break
                end
            end
            -- player is dead
            autoKillPlayers(true)
        end
    end
    if not toggle then
        _G.AutoKillPlayers = toggle;
        _G.ShouldTarget = false
    end
end

local function selectPurchase()
   local input = promptTextInput({
	Title       = "Enter the object you want to purchase",
	Placeholder = "e.g. pump;",
	MaxLength   = 15,
    })

    if not input then warn('Input not recieved') return end
    _G.Selected = input
end

local function selectedAutoPurchase(toggle)
    _G.SelectedAutoPurchase = toggle
    if not _G.SelectedAutoPurchase then return end
    while _G.SelectedAutoPurchase do
        local objectFolder = game.workspace.ClientTycoon
        for i, v in pairs(objectFolder:GetChildren()) do
            task.wait(0.5)
            local result;
            local name = v.Name
            result = containsPump(name, _G.Selected)
            if result then
                -- check price of pump compared to player
                local price = v:FindFirstChild('Cost').Value
                if not price then
                    warn('Price not found')
                    continue
                end

                local canBuy = false
                local playerMoney = getPlayerMoney()
                if not playerMoney then warn('Player money not found..') return end
                if tonumber(playerMoney) >= tonumber(price) then
                    canBuy = true
                end

                if canBuy then
                    purchaseItem(v.Name)
                end
            end
        end
    end
end

local function autoUpgradePumps(toggle)
    _G.AutoUpgrade = toggle;
    local m = 'Money'
    local s = 'Speed'
    if not _G.AutoUpgrade then return end
    while _G.AutoUpgrade do
        local clientFolder = game.workspace.ClientTycoon
        local current = m
        for i, obj in pairs(clientFolder:GetChildren()) do
            local isPump = containsPump(obj.Name, 'pump')
            if not isPump then continue end

            if current == 'Money' then
                current = s
            else
                current = m
            end

            -- upgrade
            local args = {
            workspace:WaitForChild("Kit"):WaitForChild("Tycoons"):WaitForChild("Purple Ninja"):WaitForChild("Empty"):WaitForChild("Purchased")[obj.Name],
            current
            }
            game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("UpgradePump"):FireServer(unpack(args))
            task.wait(0.5)

        end
    end
end
    
local function claimFlag()
    local centerPart = Workspace.CenterMap.center
    local Pos = centerPart:GetPivot().Position
    print(Posp)
    local newPosition = Vector3.new(Pos.x, Pos.y + 10, Pos.z)
    local myCreated = game.workspace:FindFirstChild('CreatedS') or Instance.new('Folder')
    myCreated.Name = 'CreatedS'
    myCreated.Parent = workspace
    local flatObj = myCreated:FindFirstChild('StandingPlatform') or Instance.new('Part')
    flatObj.Parent = myCreated
    flatObj.Anchored = true
    flatObj.Size = Vector3.new(20, 1, 20)
    flatObj.Name = 'StandingPlatform'
    flatObj.Transparency = 0.8
    flatObj.Position = newPosition
    -- teleport player
    local player = game.Players.LocalPlayer
    local char = player.Character
    if not char then warn('Character not found') return end
    local root = char:FindFirstChild('HumanoidRootPart')
    if not root then warn('Root not found') return end
    local fPosition = flatObj.Position
    local teleportPosition = Vector3.new(fPosition.X, fPosition.Y+10, fPosition.Z)
    local teleportCFrame = CFrame.new(teleportPosition)
    local oldPosition = root.CFrame
    root.CFrame = teleportCFrame
    -- wait 5 seconds
    task.spawn(function()
        task.wait(7)
        root.CFrame = oldPosition
    end)
end





TycoonTab:Toggle('Auto-Purchase pumps', autopurchasePumps)
TycoonTab:Toggle('Auto-Purchase everything', autopurchaseEverything)
TycoonTab:Toggle('Auto-Upgrade Pumps', autoUpgradePumps)
TycoonTab:Button('Selected', selectPurchase)
TycoonTab:Toggle('Select-purchase objects', selectedAutoPurchase)
WeaponsTab:Toggle('Toggle Silent-Aim (CROSSBOW)', crossbowSilentAimToggle)
WeaponsTab:Toggle('Toggle Auto-Kill (CROSSBOW)', autoKillPlayers)
WeaponsTab:Button('Claim Flag', claimFlag)
Script worked? 🚀 Boost it to #1 so others find it too.

Comments (0)

Log in to add a comment.