Advertisement
MaxiKaz

TycoonWall

May 28th, 2023
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.75 KB | Gaming | 0 0
  1. local przyciski = script.Parent.Przyciski
  2. local zakupy = script.Parent.Zakupy
  3.  
  4. local magazyn = {}
  5.  
  6. local DSS = game:GetService("DataStoreService")
  7. local Bank = DSS:GetDataStore("Kasa")
  8.  
  9. local podstawowe = script.Parent.Podstawowe
  10. local kierownik = script.Kierownik
  11. local drzwi = podstawowe.Drzwi
  12.  
  13. local function ukryjPrzycisk(przycisk)
  14.     przycisk.CanTouch = false
  15.     przycisk.Transparency = 1
  16.     przycisk.Tablica.Enabled = false
  17. end
  18.  
  19. local function odkryjPrzycisk(przycisk)
  20.     przycisk.CanTouch = true
  21.     przycisk.Transparency = 0
  22.     przycisk.Tablica.Enabled = true
  23. end
  24.  
  25. local function nowyPrzycisk(przycisk)
  26.     local zakup
  27.     local nazwa = przycisk.Name
  28.  
  29.     if zakupy:FindFirstChild(nazwa) then
  30.         zakup = zakupy[nazwa]
  31.         magazyn[nazwa] = zakup:Clone()
  32.         zakup:Destroy()
  33.     else
  34.         warn("Brakuje zakupu: " .. nazwa)
  35.     end
  36.  
  37.     if not (nazwa == "1") then
  38.         ukryjPrzycisk(przycisk)
  39.     end
  40.  
  41.     przycisk.Touched:Connect(function(hit)
  42.         local player = game.Players:FindFirstChild(hit.Parent.Name)
  43.  
  44.  
  45.         if player and kierownik.Value == player and game.ServerStorage[player.Name].Kasa.Value >= przycisk.Cena.Value then          
  46.  
  47.             game.ServerStorage[player.Name].Kasa.Value -= przycisk.Cena.Value
  48.  
  49.             local zakup = magazyn[nazwa]
  50.  
  51.             if zakup then
  52.                 zakup.Parent = zakupy
  53.             end
  54.  
  55.             for i, element in pairs(przycisk:GetChildren()) do
  56.                 if element.Name == "Kolejny" then
  57.  
  58.                     local przyciskDoOdkrycia = przyciski:FindFirstChild(element.Value)
  59.  
  60.                     if przyciskDoOdkrycia then
  61.                         odkryjPrzycisk(przyciskDoOdkrycia)
  62.                     else
  63.                         warn("Brakuje przycisku: " .. element.Value)
  64.                     end
  65.  
  66.                 end
  67.             end
  68.  
  69.             przycisk:Destroy()
  70.  
  71.         end
  72.     end)
  73. end
  74.  
  75. for i, przycisk in pairs(przyciski:GetChildren()) do
  76.     nowyPrzycisk(przycisk)
  77. end
  78.  
  79. -- game.Players.PlayerAdded:Connect(function(gracz)
  80. local function nowyTycoon(gracz)
  81.  
  82.     local kasa = Bank:GetAsync(gracz.UserId) or 0
  83.  
  84.     local tablicaNaSerwerze = Instance.new("Folder", game.ServerStorage)
  85.     tablicaNaSerwerze.Name = gracz.Name
  86.  
  87.     local kasaNaSerwerze = Instance.new("NumberValue", tablicaNaSerwerze)
  88.     kasaNaSerwerze.Name = "Kasa"
  89.     kasaNaSerwerze.Value = kasa
  90.  
  91.     local tablicaLokalnie = Instance.new("Folder", gracz)
  92.     tablicaLokalnie.Name = "leaderstats"
  93.  
  94.     local kasaLokalnie = Instance.new("NumberValue", tablicaLokalnie)
  95.     kasaLokalnie.Name = "Kasa"
  96.     kasaLokalnie.Value = kasa
  97.  
  98.     --  for i, przycisk in pairs(przyciski:GetChildren()) do -- usuwamy lub komentujemy
  99.     --      nowyPrzycisk(przycisk) -- usuwamy lub komentujemy
  100.     --  end -- usuwamy lub komentujemy
  101.  
  102.     --  gracz:LoadCharacter()  -- usuwamy lub komentujemy
  103.  
  104.     kasaNaSerwerze.Changed:Connect(function(liczba)
  105.         kasaLokalnie.Value = liczba
  106.     end)
  107.  
  108.     script.Parent.Podstawowe.Zbieracz.Touched:Connect(function(obiekt)
  109.         if obiekt and obiekt:FindFirstChild("Kasa") then
  110.             script.Skarbiec.Value += obiekt.Kasa.Value
  111.             obiekt:Destroy()
  112.         end
  113.     end)
  114.  
  115.     script.Parent.Podstawowe.Bank.Touched:Connect(function(obiekt)
  116.         if obiekt.Parent == gracz.Character then
  117.             kasaNaSerwerze.Value += script.Skarbiec.Value
  118.             script.Skarbiec.Value = 0
  119.         end
  120.     end)
  121.  
  122.     while true do
  123.         Bank:SetAsync(gracz.UserId, kasaNaSerwerze.Value)
  124.         print("Kasa zapisana!")
  125.         wait(10)
  126.     end
  127. end
  128. -- ) usuwamy na końcu nawias
  129.  
  130. drzwi.Touched:Connect(function(part)
  131.  
  132.     if part.Parent:FindFirstChild("Humanoid") and kierownik.Value == nil then
  133.  
  134.         local gracz = game.Players:GetPlayerFromCharacter(part.Parent)
  135.  
  136.         local posiada = false
  137.  
  138.         for i, element in pairs(game.Workspace:GetDescendants()) do
  139.             if element.Name == "System" then
  140.                 if element.Kierownik.Value == gracz then
  141.                     posiada = true
  142.                     print("Posiada")
  143.                 end
  144.             end
  145.         end
  146.  
  147.         if not posiada then
  148.             kierownik.Value = game.Players:GetPlayerFromCharacter(part.Parent)  
  149.             nowyTycoon(gracz)
  150.         end
  151.     end
  152. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement