Honansik

Tower Simulator Auto Build Script

Nov 29th, 2021
618
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local env = getgenv()
  2.  
  3. env.Settings = {
  4.     ['AutoAddBricks'] = true;
  5. }
  6.  
  7. local Settings = env.Settings
  8.  
  9. env.Players = game:GetService("Players")
  10. env.RunService = game:GetService("RunService")
  11. env.lp = Players['LocalPlayer']
  12.  
  13. local function getTower()
  14.     for index, value in next, workspace:GetChildren() do
  15.         if value.Name == "Tower" and value.Owner.Value == lp then
  16.             return value
  17.         end
  18.     end
  19. end
  20.  
  21. local function AddBricksPerSecond(Tower)
  22.     local Bricks = lp.leaderstats.Bricks.Value
  23.     local left = Tower.PurchaseUpgradeButtonLeft or nil
  24.     local right = Tower.PurchaseUpgradeButtonRight or nil
  25.     if not left or not right then return end
  26.    
  27.  
  28.     local price = tonumber( string.split(left.Head.ShopGui.Frame.Price.Text," ")[1] )
  29.    
  30.  
  31.     if Bricks > price then
  32.         Bricks = Bricks - price
  33.         lp.Character.PrimaryPart.CFrame = left.Head.CFrame
  34.         wait()
  35.         firetouchinterest(lp.Character.PrimaryPart, left.Head, 0)
  36.         firetouchinterest(lp.Character.PrimaryPart, left.Head, 1)
  37.     end
  38.    
  39.     price = tonumber( string.split(right.Head.ShopGui.Frame.Price.Text," ")[1] )
  40.    
  41.     if Bricks > price then
  42.         lp.Character.PrimaryPart.CFrame = right.Head.CFrame
  43.         wait()
  44.         firetouchinterest(lp.Character.PrimaryPart, right.Head, 0)
  45.         firetouchinterest(lp.Character.PrimaryPart, right.Head, 1)
  46.        
  47.     end
  48.    
  49. end
  50.  
  51. local function AddBricks(Tower)
  52.     fireclickdetector(Tower.ClickDetector)
  53. end
  54.  
  55. local tower = getTower()
  56.  
  57. while Settings.AutoAddBricks do
  58.     RunService.Heartbeat:wait()
  59.     AddBricks(tower)
  60.     AddBricksPerSecond(tower)
  61. end
RAW Paste Data