Advertisement
RandomMagics

Gas Station Simulator Script Working

May 24th, 2022
1,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.19 KB | None | 0 0
  1. recommended setup:
  2. use a vip server
  3. place items on shelfs then run the bots
  4. 3 accounts
  5. - one refuel also running restock
  6. - one cleaner
  7. - one cashier
  8. __________________________________________________________________________________________________________________
  9. SCRIPT:
  10. --[[
  11.  
  12. Gas Station Simulator Autofarm
  13.  
  14. Made by TheSynapseGuy on V3rm ( SomethingElse#0024 on discord )
  15. Last tested for V1.0.3
  16.  
  17. Default kebyinds
  18. P - Auto refuel
  19. L - Auto cashier
  20. M - Auto clean
  21. Z - Auto restock
  22.  
  23. VV Settings below VV
  24. ]]
  25.  
  26. local TravelSpeed = 20 -- going too fast might get you kicked
  27.  
  28. local ToggleFuelKey = Enum.KeyCode.P
  29. local ToggleCleanKey = Enum.KeyCode.M
  30. local ToggleCashierKey = Enum.KeyCode.L
  31. local ToggleRestockKey = Enum.KeyCode.Z
  32.  
  33. local AllowFuelBuy = true -- For auto refuel
  34. local AllowItemsBuy = true -- For auto restocking
  35.  
  36. local MoneySource = "Station" -- Choose "Station" or "Client"
  37. local AllowSecondarySource = true
  38. local SecondaryMoneySource = "Client" -- If Primary Money source does not have enough it will use this
  39. local AllowStationSpendingDuringBankruptcy = false -- If enabled it allows the bot to purchase using station money even when near bankruptcy
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. -- Ignore everything below here
  47. local GasEnabled = false
  48. local CleaningEnabled = false
  49. local RestockEnabled = false
  50. local CashierEnabled = false
  51. local ItemRestockQueue = {}
  52. local ReplicatedStorage = game:GetService("ReplicatedStorage"); local Players = game:GetService("Players"); local LocalPlayer = Players.LocalPlayer; local RunService = game:GetService("RunService")
  53. local ActionRemote = ReplicatedStorage:WaitForChild("Remote")
  54. local PumpsFolder = workspace:WaitForChild("Pumps")
  55. local StorageFolder = workspace:WaitForChild("Storage")
  56. local ShelvesFolder = workspace:WaitForChild("Shelves")
  57. local StatsHolder = require(ReplicatedStorage:WaitForChild("StatHolder"))
  58. local InputService = game:GetService("UserInputService")
  59. local TweenService = game:GetService("TweenService")
  60.  
  61. local function GetPlayerCharacter() return LocalPlayer.Character or LocalPlayer.CharacterAdded:wait(); end
  62. local function GetStoreGasoline() return PumpsFolder:GetAttribute("Gasoline"); end
  63. local function GetMoneyOfSource(Source : StringValue) if Source == "Station" then return workspace.Station:GetAttribute("Money") elseif Source == "Client" then return LocalPlayer:GetAttribute("Money") end end
  64. local function FindItemCatergory(ItemName : StringValue)
  65. local ShopTable = StatsHolder.Shops
  66. for FirstName,FirstCatergory in pairs(ShopTable) do
  67. if FirstCatergory ~= "Syntin Petrol Co" then
  68. for SecondName,SecondCatergory in pairs(FirstCatergory) do
  69. if SecondCatergory[ItemName] ~= nil then
  70. return {
  71. ["Item"] = ItemName,
  72. ["ItemProvider"] = FirstName,
  73. ["ItemCatergory"] = SecondName,
  74. ["ItemPrice"] = SecondCatergory[ItemName][2]
  75. }
  76. end
  77. end
  78. end
  79. end
  80. end
  81. local function DecideSource(MinimumMoneyNeeded : IntValue)
  82. local PrimarySourceMoney = GetMoneyOfSource(MoneySource)
  83. if MoneySource == "Client" then
  84. if PrimarySourceMoney >= MinimumMoneyNeeded then
  85. return MoneySource
  86. end
  87. else
  88. local StationBankrupt = not (workspace.Station:GetAttribute("Money") > workspace.Station:GetAttribute("EstBills"))
  89. if (StationBankrupt and AllowStationSpendingDuringBankruptcy) or (not StationBankrupt) then
  90. if LocalPlayer:GetAttribute("Contributions") >= MinimumMoneyNeeded then
  91. if #game.Teams.Manager:GetPlayers() > 0 then
  92. if LocalPlayer.Team == game.Teams.Manager then
  93. return MoneySource
  94. end
  95. else
  96. return MoneySource
  97. end
  98. end
  99. end
  100. end
  101. if AllowSecondarySource then
  102. local SecondarySourceMoney = GetMoneyOfSource(SecondaryMoneySource)
  103. if SecondaryMoneySource == "Client" then
  104. if SecondarySourceMoney >= MinimumMoneyNeeded then
  105. return SecondaryMoneySource
  106. end
  107. else
  108. local StationBankrupt = not (workspace.Station:GetAttribute("Money") > workspace.Station:GetAttribute("EstBills"))
  109. if (StationBankrupt and AllowStationSpendingDuringBankruptcy) or (not StationBankrupt) then
  110. if LocalPlayer:GetAttribute("Contributions") >= MinimumMoneyNeeded then
  111. if #game.Teams.Manager:GetPlayers() > 0 then
  112. if LocalPlayer.Team == game.Teams.Manager then
  113. return SecondaryMoneySource
  114. end
  115. else
  116. return SecondaryMoneySource
  117. end
  118. end
  119. end
  120. end
  121. end
  122. return MoneySource
  123. end
  124. local function BuyFuel()
  125. ActionRemote:FireServer("BuyItem","Syntin Petrol Co","Gasoline 87", 1,DecideSource(9));
  126. end
  127. local function GetPlayerStamina() return LocalPlayer:GetAttribute("Stamina"); end
  128.  
  129. if _G.dAAcG3fvBqVoPzVnAFk == nil then _G.dAAcG3fvBqVoPzVnAFk = "" end function notify(a,b,c)local d=c or function()return end;local e=b or false;if a==_G.dAAcG3fvBqVoPzVnAFk and e==false then return end;spawn(function()for f,g in pairs(game.CoreGui:GetChildren())do spawn(function()if g.Name=="MNotify"then pcall(function()g.ImageButton.ZIndex=58;g.ImageButton.TextLabel.ZIndex=59;g.ImageButton:TweenPosition(UDim2.new(0.01,0,1,0),"Out","Quint",.7,true)game:GetService("TweenService"):Create(g.ImageButton.TextLabel,TweenInfo.new(0.8,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0),{TextTransparency=1})wait(1)g:Destroy()end)end end)end;_G.dAAcG3fvBqVoPzVnAFk=a;local d=c or function()return end;local function h(i,j)local k=Instance.new(i)for f,g in pairs(j)do k[f]=g end;return k end;local l=h('ScreenGui',{DisplayOrder=0,Enabled=true,ResetOnSpawn=true,Name='MNotify',Parent=game.CoreGui})local m=h('ImageButton',{Image='rbxassetid://1051186612',ImageColor3=Color3.new(0.129412,0.129412,0.129412),ImageRectOffset=Vector2.new(0,0),ImageRectSize=Vector2.new(0,0),ImageTransparency=0,ScaleType=Enum.ScaleType.Slice,SliceCenter=Rect.new(20,20,20,20),AutoButtonColor=true,Modal=false,Selected=false,Style=Enum.ButtonStyle.Custom,Active=true,AnchorPoint=Vector2.new(0,0),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderColor3=Color3.new(0.105882,0.164706,0.207843),BorderSizePixel=1,ClipsDescendants=false,Draggable=false,Position=UDim2.new(0.00999999978,0,1,0),Rotation=0,Selectable=true,Size=UDim2.new(0,234,0,40),SizeConstraint=Enum.SizeConstraint.RelativeXY,Visible=true,ZIndex=60,Name='ImageButton',Parent=l})local n=h('TextLabel',{Font=Enum.Font.SourceSansLight,FontSize=Enum.FontSize.Size24,Text=a,TextColor3=Color3.new(0.807843,0.807843,0.807843),TextScaled=false,TextSize=24,TextStrokeColor3=Color3.new(0,0,0),TextStrokeTransparency=1,TextTransparency=0,TextWrapped=false,TextXAlignment=Enum.TextXAlignment.Center,TextYAlignment=Enum.TextYAlignment.Center,Active=false,AnchorPoint=Vector2.new(0,0),BackgroundColor3=Color3.new(1,1,1),BackgroundTransparency=1,BorderColor3=Color3.new(0.105882,0.164706,0.207843),BorderSizePixel=1,ClipsDescendants=false,Draggable=false,Position=UDim2.new(0.132478639,0,0,0),Rotation=0,Selectable=false,Size=UDim2.new(0,174,0,40),SizeConstraint=Enum.SizeConstraint.RelativeXY,Visible=true,ZIndex=61,Name='TextLabel',Parent=m})local o=h('UIListLayout',{Padding=UDim.new(0,0),FillDirection=Enum.FillDirection.Vertical,HorizontalAlignment=Enum.HorizontalAlignment.Center,SortOrder=Enum.SortOrder.Name,VerticalAlignment=Enum.VerticalAlignment.Top,Name='UIListLayout',Parent=m})local p=1;if string.len(a)<=49 then m.Size=UDim2.new(0,game:GetService("TextService"):GetTextSize(a,24,Enum.Font.SourceSansLight,Vector2.new(500,900)).X+57,0,40)elseif string.len(a)>49 then p=math.ceil(string.len(string.sub(a,49))/9)m.Size=UDim2.new(0,game:GetService("TextService"):GetTextSize(a,24,Enum.Font.SourceSansLight,Vector2.new(500+p*100,900)).X+57,0,40)end;m:TweenPosition(UDim2.new(0.01,0,1,-60),"Out","Quint",.7,true)spawn(function()wait(6.7)pcall(function()m.ZIndex=58;n.ZIndex=59;m:TweenPosition(UDim2.new(0.01,0,1,0),"Out","Quint",.7,true)_G.dAAcG3fvBqVoPzVnAFk=""wait(1)l:Destroy()end)end)m.MouseButton1Up:Connect(function()if c==nil then return end;spawn(function()pcall(function()m.ZIndex=58;n.ZIndex=59;m:TweenPosition(UDim2.new(0.01,0,1,0),"Out","Quint",.7,true)_G.dAAcG3fvBqVoPzVnAFk=""wait(1)l:Destroy()end)end)d()end)end)end
  130. function roundNumber(num, numDecimalPlaces) -- https://devforum.roblox.com/t/rounding-to-1-decimal-point/673504
  131. return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
  132. end
  133.  
  134. local function TravelToCFrame(TargetCFrame : CFrame)
  135. local PlayerCharacter = GetPlayerCharacter()
  136. if PlayerCharacter then
  137. local DistanceBetweenPoints = ( PlayerCharacter.HumanoidRootPart.Position - TargetCFrame.Position ).Magnitude
  138. local TimeNeeded = roundNumber(DistanceBetweenPoints / TravelSpeed, 3)
  139. local Tween = TweenService:Create(
  140. PlayerCharacter.HumanoidRootPart,
  141. TweenInfo.new(
  142. TimeNeeded,
  143. Enum.EasingStyle.Linear,
  144. Enum.EasingDirection.Out
  145. ),
  146. {
  147. CFrame = TargetCFrame
  148. }
  149. )
  150. Tween:Play()
  151. task.wait(TimeNeeded)
  152. end
  153. end
  154.  
  155. local function RestoreEnergy(MinimumEnergy : IntValue)
  156. notify("Resting",true)
  157. local PlayerCharacter = GetPlayerCharacter()
  158. local PreviousCFrame = PlayerCharacter.HumanoidRootPart.CFrame
  159. TravelToCFrame(workspace.Ceilings.Sofa.Seat.CFrame)
  160. task.wait(2)
  161. while true do
  162. if GetPlayerStamina() >= MinimumEnergy then
  163. break
  164. end
  165. task.wait(0.5)
  166. end
  167. PlayerCharacter.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
  168. TravelToCFrame(PreviousCFrame)
  169. end
  170.  
  171. local function FindPumpToCar(CarModel : Instance)
  172. local CarPosition = CarModel.PrimaryPart.Position
  173. local Pump
  174. local PumpDistance = 999
  175. for _,v in pairs(PumpsFolder:GetChildren()) do
  176. local DistanceBetweenPump = (CarPosition - v.Screen.Position).Magnitude
  177. if DistanceBetweenPump < PumpDistance then
  178. Pump = v
  179. PumpDistance = DistanceBetweenPump
  180. end
  181. end
  182. return Pump
  183. end
  184.  
  185. local function DoesPumpNeedToBeTakenOut(CarModel : Instance)
  186. if CarModel:FindFirstChild("Lid") then
  187. if CarModel.Lid:FindFirstChild("FinishFuel") then
  188. return true
  189. end
  190. end
  191. return false
  192. end
  193.  
  194. local function RefuelCar(CarModel : Instance)
  195. local CarPump = FindPumpToCar(CarModel)
  196. if DoesPumpNeedToBeTakenOut(CarModel) then
  197. TravelToCFrame(CarModel.Lid.CFrame)
  198. ActionRemote:FireServer("FinishFuel", CarModel, CarPump)
  199. return
  200. end
  201. if CarModel:GetAttribute("IsRefueld") or CarModel:GetAttribute("IsRefilling") then return end
  202. local RequiredFuel = CarModel:GetAttribute("RequiredFuel")
  203. local TotalAttempts = 0
  204. if AllowFuelBuy then
  205. while true do
  206. TotalAttempts += 1
  207. local StoreFuel = GetStoreGasoline()
  208. if StoreFuel >= RequiredFuel then
  209. break
  210. end
  211. notify("Attempting to buy 15L of fuel",true)
  212. BuyFuel()
  213. task.wait(1)
  214. if TotalAttempts > 10 then
  215. break
  216. end
  217. end
  218. end
  219. if GetPlayerStamina() < 5 then
  220. RestoreEnergy(95)
  221. end
  222. local StoreFuel = GetStoreGasoline()
  223. if StoreFuel >= RequiredFuel then
  224. if CarModel.Lid:FindFirstChild("Refuel") then
  225. TravelToCFrame(CarModel.Lid.CFrame)
  226. notify("Refilling "..CarModel.Name,true)
  227. ActionRemote:FireServer("FuelCustomer", CarModel, CarPump)
  228. task.wait(4)
  229. end
  230. end
  231. end
  232. local PreviousItem
  233. local function ScanItem(Item : Instance, CashierModel : Instance)
  234. if GetPlayerStamina() < 5 then
  235. RestoreEnergy(95)
  236. end
  237. if Item ~= PreviousItem then
  238. local DistanceFromItem = ( Item.Root.Position - GetPlayerCharacter().HumanoidRootPart.Position ).Magnitude
  239. if DistanceFromItem > 10 then
  240. notify("Too far away from cash register",true)
  241. TravelToCFrame(CFrame.new(1.46752572, 3, -6.53523779, 0.726744831, -4.74023416e-08, 0.68690753, 9.53963948e-08, 1, -3.19205924e-08, -0.68690753, 8.87266296e-08, 0.726744831))
  242. end
  243. if Item.Root:FindFirstChild("Scan") then
  244. if Item.Root:FindFirstChild("Scan").Enabled then
  245. if not CashierModel:GetAttribute("InUse") then
  246. notify("Scanning "..Item.Name,true)
  247. ActionRemote:FireServer("ScanItem",Item,CashierModel)
  248. Item.Root:FindFirstChild("Scan").Enabled = false
  249. PreviousItem = Item
  250. task.wait(3)
  251. end
  252. end
  253. end
  254. end
  255. end
  256. InputService.InputBegan:Connect(function(input, gameProcessedEvent)
  257. if not gameProcessedEvent then
  258. if input.KeyCode == ToggleFuelKey then
  259. GasEnabled = not GasEnabled
  260. notify("Fuel enabled: "..tostring(GasEnabled),true)
  261. end
  262. if input.KeyCode == ToggleCashierKey then
  263. CashierEnabled = not CashierEnabled
  264. notify("Cashier enabled: "..tostring(CashierEnabled),true)
  265. end
  266. if input.KeyCode == ToggleCleanKey then
  267. CleaningEnabled = not CleaningEnabled
  268. notify("Cleaning enabled: "..tostring(CleaningEnabled),true)
  269. end
  270. if input.KeyCode == ToggleRestockKey then
  271. RestockEnabled = not RestockEnabled
  272. notify("Restocking enabled: "..tostring(RestockEnabled),true)
  273. if not RestockEnabled then
  274. ItemRestockQueue = {}
  275. end
  276. end
  277. end
  278. end)
  279.  
  280. local function ItemRemoved(Item : Instance, Shelf : Instance)
  281. if RestockEnabled then
  282. table.insert(ItemRestockQueue,{
  283. ["ItemShelf"] = Shelf,
  284. ["ItemType"] = Item.Name,
  285. ["ItemCFrame"] = Item.PrimaryPart.CFrame - Vector3.new(0,Item.PrimaryPart.Size.Y/2,0)
  286. })
  287. end
  288. end
  289. local function NewShelfAdded(shelf : Instance)
  290. if shelf:FindFirstChild("Content") then
  291. shelf.Content.ChildRemoved:connect(function(Item)
  292. ItemRemoved(Item,shelf)
  293. end)
  294. end
  295. end
  296.  
  297. for _,v in pairs(ShelvesFolder:GetChildren()) do
  298. NewShelfAdded(v)
  299. end
  300. ShelvesFolder.ChildAdded:Connect(NewShelfAdded)
  301.  
  302. while true do
  303. task.wait(0.1)
  304. if GasEnabled then
  305. pcall(function()
  306. for _,v in pairs(workspace:GetChildren()) do
  307. if v.Name:sub(1,4) == "Car_" then
  308. RefuelCar(v)
  309. task.wait(1)
  310. end
  311. end
  312. end)
  313. end
  314. if CashierEnabled then
  315. pcall(function()
  316. for _,v in pairs(workspace.Checkouts:GetChildren()) do
  317. for _,h in pairs(v.Items:GetChildren()) do
  318. ScanItem(h,v)
  319. end
  320. end
  321. end)
  322. end
  323. if CleaningEnabled then
  324. pcall(function()
  325. if GetPlayerStamina() < 5 then
  326. RestoreEnergy(95)
  327. end
  328. for _,v in pairs(workspace.Windows:GetChildren()) do
  329. if v:FindFirstChild("Attachment") then
  330. if v.Attachment.Clean.Enabled then
  331. if GetPlayerStamina() < 5 then
  332. RestoreEnergy(95)
  333. end
  334. notify("Cleaning window",true)
  335. TravelToCFrame(v.CFrame)
  336. ActionRemote:FireServer("Clean",v.Attachment.Clean)
  337. task.wait(4)
  338. end
  339. end
  340. end
  341. for _,v in pairs(workspace:GetChildren()) do
  342. if v.Name == "Spot" then
  343. if GetPlayerStamina() < 5 then
  344. RestoreEnergy(95)
  345. end
  346. notify("Cleaning spot")
  347. TravelToCFrame(v.CFrame + Vector3.new(0,3,0))
  348. ActionRemote:FireServer("Clean",v.Clean)
  349. task.wait(1)
  350. end
  351. end
  352. end)
  353. end
  354. if RestockEnabled then
  355. pcall(function()
  356. if #ItemRestockQueue >= 1 then
  357. local ItemRestockQueueCache = ItemRestockQueue
  358. ItemRestockQueue = {}
  359. for _, iteminfo in pairs(ItemRestockQueueCache) do
  360. if GetPlayerStamina() < 5 then
  361. RestoreEnergy(95)
  362. end
  363. if StorageFolder:FindFirstChild(iteminfo["ItemType"]) then
  364. local RemainingItems = StorageFolder:FindFirstChild(iteminfo["ItemType"]):GetAttribute("Storage")
  365. if RemainingItems <= 0 then
  366. if AllowItemsBuy then
  367. ItemShopInfo = FindItemCatergory(iteminfo["ItemType"])
  368. local Attempts = 0
  369. while true do
  370. Attempts += 1
  371. RemainingItems = StorageFolder:FindFirstChild(iteminfo["ItemType"]):GetAttribute("Storage")
  372. if RemainingItems > 0 then
  373. break
  374. end
  375. if Attempts > 5 then
  376. break
  377. end
  378. notify("Attempting to buy "..iteminfo["ItemType"],true)
  379. ActionRemote:FireServer("BuyItem",ItemShopInfo["ItemProvider"],ItemShopInfo["ItemCatergory"], iteminfo["ItemType"],DecideSource(ItemShopInfo["ItemPrice"]));
  380. task.wait(1.5)
  381. end
  382. end
  383. end
  384. RemainingItems = StorageFolder:FindFirstChild(iteminfo["ItemType"]):GetAttribute("Storage")
  385. if RemainingItems > 0 then
  386. --TravelToCFrame(iteminfo["ItemShelf"].PrimaryPart.CFrame) not really needed
  387. ActionRemote:FireServer("PlaceProduct",iteminfo["ItemType"],iteminfo["ItemCFrame"])
  388. notify("Restocked "..iteminfo["ItemType"],true)
  389. else
  390. notify("Failed to restock "..iteminfo["ItemType"]..", not enough stock",true)
  391. end
  392. end
  393. end
  394. end
  395. end)
  396. end
  397. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement