local Players = game:GetService("Players") local player = Players.LocalPlayer local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui")) gui.Name = "TurnBattlePixelGUI" gui.ResetOnSpawn = false local TOTAL_MONSTERS = 15 local MAX_HP = 120 local monsters = { {name="Slime",baseHp=40,image="rbxassetid://872974408"}, {name="Bat",baseHp=55,image="rbxassetid://4018901703"}, {name="Skeleton",baseHp=75,image="rbxassetid://426644465"}, {name="Golem",baseHp=110,image="rbxassetid://216330870"}, {name="Dragon",baseHp=160,image="rbxassetid://57248129"}, {name="Goblin",baseHp=180,image="rbxassetid://321719167"}, {name="Zombie",baseHp=200,image="rbxassetid://2716943898"}, {name="Witch",baseHp=230,image="rbxassetid://6740442482"}, {name="Knight",baseHp=260,image="rbxassetid://112804846"}, {name="Demon",baseHp=300,image="rbxassetid://10528567067"}, {name="Ogre",baseHp=350,image="rbxassetid://1666920728"}, {name="Phantom",baseHp=400,image="rbxassetid://2289826763"}, {name="Hydra",baseHp=480,image="rbxassetid://151340278"}, {name="Titan",baseHp=600,image="rbxassetid://176863221"}, {name="Dark Lord",baseHp=750,image="rbxassetid://9856271964"}, } local shopItems = { {name="Wood Sword",dmg=25,cost=0,type="weapon"}, {name="Iron Sword",dmg=35,cost=25,type="weapon"}, {name="Steel Blade",dmg=50,cost=50,type="weapon"}, {name="Magic Edge",dmg=70,cost=85,type="weapon"}, {name="Dragon Slayer",dmg=100,cost=120,type="weapon"}, {name="Celestial Saber",dmg=140,cost=180,type="weapon"}, {name="Health Potion (+60 HP)",heal=60,cost=25,type="potion"}, {name="Leather Armor",reduction=0.1,cost=20,type="armor"}, {name="Chainmail Armor",reduction=0.2,cost=50,type="armor"}, {name="Steel Armor",reduction=0.35,cost=90,type="armor"}, } local frame = Instance.new("Frame", gui) frame.Size = UDim2.new(0, 560, 0, 380) frame.Position = UDim2.new(0.5, -280, 0.5, -190) frame.BackgroundColor3 = Color3.fromRGB(18,18,25) frame.BorderSizePixel = 0 local title = Instance.new("TextLabel", frame) title.AnchorPoint = Vector2.new(0.5,0) title.Position = UDim2.new(0.5, 0, 0, 8) title.Size = UDim2.new(0.9, 0, 0, 36) title.BackgroundTransparency = 1 title.Text = "⚔️ Retro Turn Battle" title.TextScaled = true title.TextColor3 = Color3.fromRGB(255,255,255) title.Font = Enum.Font.SourceSansBold local battleArea = Instance.new("Frame", frame) battleArea.Size = UDim2.new(0.96, 0, 0.6, 0) battleArea.Position = UDim2.new(0.02, 0, 0.12, 0) battleArea.BackgroundTransparency = 1 local playerSprite = Instance.new("ImageLabel", battleArea) playerSprite.Size = UDim2.new(0, 110, 0, 110) playerSprite.Position = UDim2.new(0.06, 0, 0.15, 0) playerSprite.BackgroundTransparency = 1 playerSprite.Image = "rbxassetid://0" local monsterContainer = Instance.new("Frame", battleArea) monsterContainer.Size = UDim2.new(0, 220, 0, 170) monsterContainer.Position = UDim2.new(0.52, 0, 0.12, 0) monsterContainer.BackgroundTransparency = 1 local monsterImage = Instance.new("ImageLabel", monsterContainer) monsterImage.Size = UDim2.new(0, 160, 0, 120) monsterImage.Position = UDim2.new(0.5, -80, 0, 0) monsterImage.BackgroundTransparency = 1 monsterImage.Image = "rbxassetid://0" local monsterNameLabel = Instance.new("TextLabel", monsterContainer) monsterNameLabel.Size = UDim2.new(1, 0, 0, 24) monsterNameLabel.Position = UDim2.new(0, 0, 0.73, 0) monsterNameLabel.BackgroundTransparency = 1 monsterNameLabel.TextScaled = true monsterNameLabel.TextColor3 = Color3.new(1,1,1) monsterNameLabel.Font = Enum.Font.SourceSansBold local playerHPLabel = Instance.new("TextLabel", frame) playerHPLabel.Position = UDim2.new(0.06, 0, 0.74, 0) playerHPLabel.Size = UDim2.new(0.4, 0, 0, 28) playerHPLabel.BackgroundTransparency = 1 playerHPLabel.TextScaled = true playerHPLabel.TextColor3 = Color3.fromRGB(141,255,147) local monsterHPLabel = Instance.new("TextLabel", frame) monsterHPLabel.Position = UDim2.new(0.54, 0, 0.74, 0) monsterHPLabel.Size = UDim2.new(0.4, 0, 0, 28) monsterHPLabel.BackgroundTransparency = 1 monsterHPLabel.TextScaled = true monsterHPLabel.TextColor3 = Color3.fromRGB(255,150,150) local infoLabel = Instance.new("TextLabel", frame) infoLabel.Position = UDim2.new(0.05, 0, 0.82, 0) infoLabel.Size = UDim2.new(0.9, 0, 0, 30) infoLabel.BackgroundTransparency = 1 infoLabel.TextScaled = true infoLabel.TextColor3 = Color3.fromRGB(220,220,220) infoLabel.Text = "Battle Start!" local attackBtn = Instance.new("TextButton", frame) attackBtn.Position = UDim2.new(0.05, 0, 0.88, 0) attackBtn.Size = UDim2.new(0.25, 0, 0.08, 0) attackBtn.Text = "Attack ⚔️" attackBtn.TextScaled = true local usePotionBtn = Instance.new("TextButton", frame) usePotionBtn.Position = UDim2.new(0.35, 0, 0.88, 0) usePotionBtn.Size = UDim2.new(0.25, 0, 0.08, 0) usePotionBtn.Text = "Use Potion 💖" usePotionBtn.TextScaled = true local shopBtn = Instance.new("TextButton", frame) shopBtn.Position = UDim2.new(0.66, 0, 0.88, 0) shopBtn.Size = UDim2.new(0.28, 0, 0.08, 0) shopBtn.Text = "Shop 🛒" shopBtn.TextScaled = true local shopFrame = Instance.new("Frame", gui) shopFrame.Size = UDim2.new(0,420,0,320) shopFrame.Position = UDim2.new(0.5,-210,0.5,-160) shopFrame.BackgroundColor3 = Color3.fromRGB(28,28,36) shopFrame.Visible = false local shopTitle = Instance.new("TextLabel", shopFrame) shopTitle.Size = UDim2.new(1,0,0,36) shopTitle.Text = "Shop" shopTitle.TextScaled = true shopTitle.BackgroundTransparency = 1 shopTitle.TextColor3 = Color3.new(1,1,1) shopTitle.Font = Enum.Font.SourceSansBold local coinsLabel = Instance.new("TextLabel", shopFrame) coinsLabel.Size = UDim2.new(1,0,0,24) coinsLabel.Position = UDim2.new(0,0,0.12,0) coinsLabel.Text = "Coins: 0" coinsLabel.TextScaled = true coinsLabel.BackgroundTransparency = 1 coinsLabel.TextColor3 = Color3.fromRGB(255,255,150) local backShopBtn = Instance.new("TextButton", shopFrame) backShopBtn.Size = UDim2.new(0.3,0,0.12,0) backShopBtn.Position = UDim2.new(0.35,0,0.85,0) backShopBtn.Text = "Back" backShopBtn.TextScaled = true local shopButtons = {} for i,item in ipairs(shopItems) do local btn = Instance.new("TextButton", shopFrame) btn.Size = UDim2.new(0.9,0,0,36) btn.Position = UDim2.new(0.05,0,0.18+(i-1)*0.1,0) btn.TextScaled = true btn.Text = (item.type=="weapon" and (item.name.." ("..item.dmg.." dmg)") or item.type=="armor" and (item.name.." ("..(item.reduction*100).."%)") or item.name).." - "..item.cost.."c" shopButtons[i] = btn end local coins = 0 local potions = 0 local monstersDefeated = 0 local currentMonsterHP = 0 local currentMonsterIndex = 1 local playerHP = MAX_HP local weapon = shopItems[1] local currentArmor = nil local turn = "player" local function updateHUD() playerHPLabel.Text = "Player HP: "..playerHP.."/"..MAX_HP monsterHPLabel.Text = "Monster HP: "..math.max(currentMonsterHP,0) coinsLabel.Text = "Coins: "..coins.." | Potions: "..potions end local function newMonster() monstersDefeated += 1 currentMonsterIndex = math.clamp(monstersDefeated,1,#monsters) local data = monsters[currentMonsterIndex] currentMonsterHP = data.baseHp + (monstersDefeated * 8) monsterNameLabel.Text = data.name.." (Lv "..monstersDefeated..")" monsterImage.Image = data.image infoLabel.Text = "A wild "..data.name.." appears!" -- Add Mega Potion to shop after round 8 local megaExists = false for _,item in ipairs(shopItems) do if item.name == "Mega Potion (+120 HP)" then megaExists = true break end end if monstersDefeated >= 8 and not megaExists then table.insert(shopItems, {name="Mega Potion (+120 HP)",heal=120,cost=50,type="potion"}) local btn = Instance.new("TextButton", shopFrame) btn.Size = UDim2.new(0.9,0,0,36) btn.Position = UDim2.new(0.05,0,0.18+(#shopItems-1)*0.1,0) btn.TextScaled = true btn.Text = "Mega Potion (+120 HP) - 50c" shopButtons[#shopButtons+1] = btn btn.MouseButton1Click:Connect(function() local item = shopItems[#shopItems] if coins < item.cost then infoLabel.Text = "Not enough coins!" return end coins -= item.cost potions += 1 infoLabel.Text = "Bought a Mega Potion! You now have "..potions.."." updateHUD() end) end updateHUD() end local function endGame(result) local overlay = Instance.new("Frame", gui) overlay.Size = UDim2.new(1,0,1,0) overlay.BackgroundColor3 = Color3.new(0,0,0) overlay.BackgroundTransparency = 0.4 local msg = Instance.new("TextLabel", overlay) msg.Size = UDim2.new(1,0,0,50) msg.Position = UDim2.new(0,0,0.4,0) msg.Text = result=="win" and "🏆 You defeated all monsters!" or "💀 You were defeated!" msg.TextScaled = true msg.BackgroundTransparency = 1 msg.TextColor3 = Color3.new(1,1,1) local restart = Instance.new("TextButton", overlay) restart.Size = UDim2.new(0.3,0,0.08,0) restart.Position = UDim2.new(0.35,0,0.6,0) restart.Text = "Restart" restart.TextScaled = true restart.MouseButton1Click:Connect(function() gui:Destroy() script:Destroy() end) end attackBtn.MouseButton1Click:Connect(function() if turn ~= "player" then return end turn = "busy" -- Give 5 coins per attack coins += 5 local dmg = weapon.dmg currentMonsterHP -= dmg infoLabel.Text = "You dealt "..dmg.." damage! +5 coins" updateHUD() if currentMonsterHP <= 0 then coins += 25 -- coins for killing monster infoLabel.Text = "Monster defeated! +25 coins" if monstersDefeated >= TOTAL_MONSTERS then wait(1) endGame("win") return end wait(1) newMonster() turn = "player" return end wait(0.7) local mdmg = math.random(10 + monstersDefeated, 18 + monstersDefeated) local damageTaken = mdmg if currentArmor then damageTaken = math.floor(mdmg * (1 - currentArmor.reduction)) end playerHP -= damageTaken infoLabel.Text = "Monster hit you for "..damageTaken.."!" updateHUD() if playerHP <= 0 then endGame("lose") else turn = "player" end end) usePotionBtn.MouseButton1Click:Connect(function() if turn ~= "player" or potions <= 0 then return end local healed = math.min(60, MAX_HP - playerHP) potions -= 1 playerHP += healed infoLabel.Text = "Used a potion! Restored "..healed.." HP. ("..potions.." left)" updateHUD() end) shopBtn.MouseButton1Click:Connect(function() shopFrame.Visible = not shopFrame.Visible end) backShopBtn.MouseButton1Click:Connect(function() shopFrame.Visible = false end) for i,btn in ipairs(shopButtons) do btn.MouseButton1Click:Connect(function() local item = shopItems[i] if coins < item.cost then infoLabel.Text = "Not enough coins!" return end coins -= item.cost if item.type == "weapon" then weapon = item infoLabel.Text = "Equipped "..item.name.."!" elseif item.type == "potion" then potions += 1 infoLabel.Text = "Bought a potion! You now have "..potions.."." elseif item.type == "armor" then currentArmor = item infoLabel.Text = "Equipped "..item.name.."! Damage reduced by "..(item.reduction*100).."%" end updateHUD() end) end newMonster() updateHUD()