Advertisement
MahDev

Goat Tycoon

May 15th, 2025
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.42 KB | None | 0 0
  1. local plot = {}
  2. local Zone = require(script.Parent.Zone)
  3. local Data = require(script.Parent.DataManger)
  4. local process = require(script.Parent.Process)
  5. local NumberAnimation = require(script.Parent.NumberAnimation)
  6.  
  7. plot.__index = plot
  8.  
  9. plot.GoatInfo = {["Normal Goat"] = {["Give"] = 1, ["Color"] = Color3.fromRGB(250, 250, 250)},
  10. ["Chocolate Goat"] = {["Need"] = {["Normal Goat"] = 6}  ,["Give"] = 10, ["Color"] = Color3.fromRGB(99, 95, 98)},
  11. ["Strawberry Goat"] = {["Need"] = {["Chocolate Goat"] = 5} ,["Give"] = 50, ["Color"] = Color3.fromRGB(106, 57, 9)},
  12. ["Mango Goat"] = {["Need"] = {["Strawberry Goat"] = 4},["Give"] = 200, ["Color"] = Color3.fromRGB(245, 205, 48)},
  13. ["Lemon Goat"] = {["Need"] = {["Mango Goat"] = 3} ,["Give"] = 650, ["Color"] = Color3.fromRGB(52, 142, 64)},
  14. ["Kiwi Goat"] = {["Need"] = {["Lemon Goat"] = 3} ,["Give"] = 2000, ["Color"] = Color3.fromRGB(77, 107, 141)},
  15. ["Silver Goat"] = {["Need"] = {["Kiwi Goat"] = 3} ,["Give"] = 6500, ["Color"] = Color3.fromRGB(171, 60, 60)},
  16. ["Gold Goat"] = {["Need"] = {["Silver Goat"] = 3} ,["Give"] = 25000},
  17. ["Diamond Goat"] = {["Need"] = {["Gold Goat"] = 2} ,["Give"] = 45000},
  18. ["Amethyst Goat"] = {["Need"] = {["Diamond Goat"] = 2} ,["Give"] = 100000},
  19. ["Rainbow Goat"] = {["Need"] = {["Amethyst Goat"] = 2} ,["Give"] = 250000}
  20.  
  21. }
  22.  
  23. plot.strongestGoat = {["Rainbow"] = 11  ,["Amethyst"] = 10,["Diamond"] = 9 ,["Gold"] = 8,["Silver"] = 7 ,["Kiwi"] = 6 ,["Lemon"] =5, ["Mango"] =4,["Strawberry"] = 3,["Chocolate"] = 2 ,["Normal"] = 1}
  24.  
  25. local tween = game:GetService("TweenService")
  26. function plot.New(plr)
  27.  
  28.     local self = {}
  29.     self.plr = plr
  30.  
  31.     return setmetatable(self,plot)
  32. end
  33.  
  34. function plot.EnterZone(plr,deb,plot1,obj:Instance)
  35.     local tweeninfo = TweenInfo.new(0.2,Enum.EasingStyle.Quint,Enum.EasingDirection.In,0)
  36.     local endpos = tween:Create(obj.Button,tweeninfo,{CFrame =obj.Endposition.CFrame })
  37.  
  38.     local oldCFrame = obj.Button.CFrame
  39.  
  40.     deb[obj.Name] = true
  41.     endpos:Play()
  42.  
  43.     endpos.Completed:Connect(function()
  44.         game.ReplicatedStorage.events.Sound:FireClient(plr,"Button")
  45.  
  46.         local start = tween:Create(obj.Button,tweeninfo,{CFrame =oldCFrame })
  47.         start:Play()
  48.         start.Completed:Wait()
  49.        
  50.     end)
  51.  
  52.  
  53. end
  54.  
  55. function plot:ChoosePlotrandomly(chr)--======>Choosing random plot
  56.  
  57.  
  58.     local tab = {}
  59.  
  60.     for i,v in pairs(workspace.Plots:GetChildren())do
  61.         if v:IsA("Model") then
  62.             if v:GetAttribute("Owner") == "" then
  63.                 table.insert(tab,v)
  64.             end
  65.         end
  66.     end
  67.     local random = math.random(1,#tab)
  68.     tab[random]:SetAttribute("Owner",self.plr.Name)
  69.  
  70.  
  71.     return tab[random]
  72.  
  73. end
  74.  
  75.  
  76.  
  77. function plot:SetNameOnSign(plot,Text)--======>Set Name Of Player on tycoon sign
  78.  
  79.     plot.Decor.Entry.Part1.SurfaceGui.TextLabel.Text = Text
  80.  
  81. end
  82.  
  83. function plot.LoadingInfoGoatType(plot)--======>Put Info Merge goat at board
  84.  
  85.     for i,v in pairs(plot.Decor.Board.GUI.SurfaceGui:GetChildren())do
  86.         if v:IsA("TextLabel") then
  87.             v.Visible = not v.Visible
  88.         end
  89.     end
  90. end
  91.  
  92. function plot.PutGoatinBern(plot1,typee,Data1,Status)--======>Put Goats In Bern
  93.  
  94.     local tab = {}
  95.    
  96.     for i,v in pairs(plot1.Bern.Places:GetChildren())do
  97.         if v:IsA("Model") then
  98.             if not v:GetAttribute("IsFull") then
  99.                 for l,m in pairs(v.Places:GetChildren())do
  100.                     if m:IsA("Part") then
  101.                         if not m:GetAttribute("IsFull") then
  102.                             table.insert(tab,m)
  103.                         end
  104.                     end
  105.                 end
  106.             end
  107.         end
  108.     end
  109.     if #tab ~= 0 then
  110.         tab[1]:SetAttribute("IsFull",true)
  111.         if typee == "Rainbow" then
  112.             local clone:Model =  game.ServerStorage.Storage.Goats[typee.." Goat"]:Clone()
  113.             clone.Parent= tab[1].Parent.Parent.Parent.Parent.Goats
  114.             clone:PivotTo(tab[1].CFrame *CFrame.Angles(0,math.rad(-90),0)* CFrame.new(0,0.5,0))  
  115.             clone.Name = "Goat"..#tab[1].Parent.Parent.Parent.Parent.Goats:GetChildren()
  116.             if Status ~= "Load" then
  117.  
  118.                 table.insert(Data1.GoatsInBern,typee)
  119.  
  120.             end
  121.  
  122.             clone:SetAttribute("Type",typee)
  123.             if clone:FindFirstChild("Yes") then
  124.                 local cor = coroutine.create(function()
  125.                     while task.wait() do
  126.                         if clone:FindFirstChild("Yes") then
  127.                             local t = 10;
  128.                             local hue = tick() % t / t
  129.                             local colorrr = Color3.fromHSV(hue, 1, 1)
  130.                             clone.Yes.Color = colorrr
  131.                         end
  132.  
  133.  
  134.                     end
  135.                 end)
  136.                 coroutine.resume(cor)
  137.             end
  138.  
  139.  
  140.         else
  141.             local clone:Model =  game.ServerStorage.Storage.Goats[typee.." Goat"]:Clone()
  142.             clone.Parent= tab[1].Parent.Parent.Parent.Parent.Goats
  143.             clone:PivotTo(tab[1].CFrame *CFrame.Angles(0,math.rad(-90),0)* CFrame.new(0,0.5,0))  
  144.             clone.Name = "Goat"..#tab[1].Parent.Parent.Parent.Parent.Goats:GetChildren()
  145.             if Status ~= "Load" then
  146.                 table.insert(Data1.GoatsInBern,typee)
  147.             end
  148.             clone:SetAttribute("Type",typee)
  149.         end
  150.     else
  151.         local clonebern = game.ServerStorage.Storage.Temp1:Clone()
  152.         clonebern:SetPrimaryPartCFrame(plot1.Bern.Places["Temp"..#plot1.Bern.Places:GetChildren()]:GetPrimaryPartCFrame()* CFrame.new(0,9,0))
  153.         plot1.Bern.Places["Temp"..#plot1.Bern.Places:GetChildren()]:SetAttribute("IsFull", true)
  154.         clonebern.Parent = plot1.Bern.Places
  155.         clonebern.Name = "Temp"..#plot1.Bern.Places:GetChildren()
  156.         plot1.Bern.Roof:SetPrimaryPartCFrame(plot1.Bern.Places["Temp"..#plot1.Bern.Places:GetChildren()]:GetPrimaryPartCFrame()* CFrame.new(0,7,0))
  157.         for i,v in pairs(plot1.Bern.Collide:GetChildren())do
  158.             if v:IsA("BasePart") then
  159.                 v.Size =  Vector3.new(v.Size.X,v.Size.Y + 16,v.Size.Z)
  160.             end
  161.         end
  162.         plot.PutGoatinBern(plot1,typee,Data1,Status)
  163.     end
  164. end
  165.  
  166. function plot.ConvertGoat(tab1,Type:string,Convert:string)--=======>Converting Goats
  167.  
  168.     local amount= 0
  169.     for i,v in pairs(tab1)do
  170.         if v == Type then
  171.  
  172.             amount +=1
  173.             if amount >= plot.GoatInfo[Convert.." Goat"].Need[Type.." Goat"] then
  174.                 for l = plot.GoatInfo[Convert.." Goat"].Need[Type.." Goat"] ,1,-1 do
  175.  
  176.                     local index = table.find(tab1,Type)
  177.                     table.remove(tab1,index)
  178.  
  179.  
  180.                 end
  181.                 table.insert(tab1,Convert)
  182.  
  183.                 amount = 0
  184.                 plot.ConvertGoat(tab1,Type,Convert)
  185.  
  186.  
  187.             end
  188.  
  189.         end
  190.     end
  191.     if amount<plot.GoatInfo[Convert.." Goat"].Need[Type.." Goat"] then
  192.         return tab1 , true
  193.     end
  194.  
  195.  
  196. end
  197.  
  198. function plot.SortTableToHigher(tablee)--=========>Sort Table goat fron lower To Higher
  199.     for i,v in pairs(tablee)do
  200.         tablee[i] = plot.strongestGoat[v]
  201.  
  202.     end
  203.     table.sort(tablee,function(a,b)
  204.         if a > b then
  205.             return true
  206.         end
  207.     end)
  208.  
  209.     for i,v in pairs(tablee)do
  210.         for l,m in pairs(plot.strongestGoat)do
  211.             if m ==v then
  212.                 tablee[i] = l
  213.             end
  214.         end
  215.  
  216.     end
  217.     return tablee
  218.  
  219. end
  220. function plot.PutGoatTable(plot1)--==============> Put Current Goat At table
  221.     local tab = {}
  222.  
  223.     for i,v:Model in pairs(plot1.Bern.Goats:GetChildren())do
  224.         if v:IsA("Model") then
  225.             table.insert(tab,v:GetAttribute("Type"))
  226.             v:Destroy()
  227.         end
  228.     end
  229.     for i,v in pairs(plot1.Bern.Places:GetChildren())do
  230.         if v.Name ~= "Temp1" then
  231.             v:Destroy()
  232.             plot1.Bern.Roof:SetPrimaryPartCFrame(plot1.Bern.Places["Temp1"]:GetPrimaryPartCFrame()* CFrame.new(0,7,0))
  233.         end
  234.     end
  235.     for l,m in pairs(plot1.Bern.Places["Temp1"].Places:GetChildren())do
  236.         if m:IsA("BasePart") then
  237.             m:SetAttribute("IsFull",false)
  238.         end
  239.     end
  240.     plot1.Bern.Places["Temp1"]:SetAttribute("IsFull",false)
  241.     return tab
  242. end
  243.  
  244. function plot.mergeGoats(tab) --=========>merge Table Function
  245.     local tab1,isDone = plot.ConvertGoat(tab,"Normal","Chocolate")
  246.     if isDone then
  247.         local tab2,isDone2 = plot.ConvertGoat(tab1,"Chocolate","Strawberry")
  248.        
  249.         if isDone2 then
  250.             local tab3,isDone3 = plot.ConvertGoat(tab2,"Strawberry","Mango")
  251.             if isDone3 then
  252.                 local tab4,isDone4 = plot.ConvertGoat(tab3,"Mango","Lemon")
  253.                 if isDone4 then
  254.                     local tab5,isDone5 = plot.ConvertGoat(tab4,"Lemon","Kiwi")
  255.                     if isDone5 then
  256.                         local tab6,isDone6 = plot.ConvertGoat(tab5,"Kiwi","Silver")
  257.                         if isDone6 then
  258.                             local tab7,isDone7 = plot.ConvertGoat(tab6,"Silver","Gold")
  259.                             if isDone7 then
  260.                                 local tab8,isDone8 = plot.ConvertGoat(tab7,"Gold","Diamond")
  261.                                 if isDone8 then
  262.                                     local tab9,isDone9 = plot.ConvertGoat(tab8,"Diamond","Amethyst")
  263.                                     if isDone9 then
  264.                                         local tab10,isDone10 = plot.ConvertGoat(tab9,"Amethyst","Rainbow")
  265.                                        
  266.                                         return tab10 , isDone10
  267.                                     end
  268.                                 end
  269.                             end
  270.                            
  271.                         end
  272.                     end
  273.                 end
  274.             end
  275.         end
  276.     end
  277. end
  278.  
  279. function plot:ClaimMilkByPlayer(plot1:Instance,data:Data)--============>Claim Milk Function
  280.     local deb = {}
  281.     local cor = coroutine.create(function()
  282.         while wait(0.002)do
  283.             if not plot1:FindFirstChild("Bern") then  break end
  284.             if plot1.Bern.Stopped.Value == true then break end
  285.             for i,v in pairs(plot1.Bern.Milks:GetChildren())do
  286.                 if v:IsA("Model") then
  287.  
  288.                     if self.plr:DistanceFromCharacter(v.Part.Position) <= 4.5 and v:GetAttribute("Owner") == self.plr.Name then
  289.  
  290.                         if not deb[self.plr] then
  291.                             deb[self.plr] = true
  292.  
  293.                             game.ReplicatedStorage.events.Popup:FireClient(self.plr,v:GetAttribute("Amount"))
  294.                             self.plr.leaderstats.Milk.Value += v:GetAttribute("Amount")
  295.                             data.Milk = self.plr.leaderstats.Milk.Value
  296.                            
  297.                             v:Destroy()
  298.                             game.ReplicatedStorage.events.Sound:FireClient(self.plr,"sound")
  299.                             --game:GetService("Debris"):AddItem(clone2,0.001)
  300.                             for l,m in ipairs(plot1.Bern.Milks:GetChildren())do
  301.                                 m.Name = "Milk"..l
  302.                             end
  303.  
  304.                             plot1.Bern.limitedMode.Value = false
  305.  
  306.  
  307.                             deb[self.plr] = false
  308.                         else
  309.                            
  310.                         end
  311.  
  312.                     end
  313.                 end
  314.             end
  315.  
  316.  
  317.  
  318.         end
  319.     end)
  320.  
  321.     coroutine.resume(cor)
  322.  
  323.  
  324. end
  325.  
  326.  
  327.  
  328.  
  329. function plot:SetAllSettingsForPlot(plot1,chr)
  330.  
  331.     plot.LoadingInfoGoatType(plot1)
  332.     local data = Data:Get(self.plr)
  333.     local sell = process.New(self.plr,chr,plot1)
  334.     local tweeninfo = TweenInfo.new(0.2,Enum.EasingStyle.Quint,Enum.EasingDirection.In,0)
  335.     local deb = {}
  336.     local container = plot1.buttons["1Goat"].Zone
  337.     local zone = Zone.new(container)
  338.     local zone2 = Zone.new(plot1.buttons["6Goat"].Zone)
  339.     local zone3 = Zone.new(plot1["Merge Button"].Zone)
  340.     local zone4 = Zone.new(plot1["Sell Button"].Zone)
  341.     local sell1 = Zone.new(plot1.buttons.Speed1Sell)
  342.     local sell10 = Zone.new(plot1.buttons.Speed10Sell)
  343.     local procces1 = Zone.new(plot1.buttons.Speed1Storage)
  344.     local procces10 = Zone.new(plot1.buttons.Speed10Storage)
  345.     local deblimied
  346.  
  347.     local MilkNumberAnimation = NumberAnimation.new(plot1.CompressorParts.ye.BillboardGui.TextLabel, self.plr.Values.Storage, {
  348.         Style = "Tween",
  349.         Time = 0.4,
  350.         EasingStyle = "Quad",
  351.         EasingDirection = "InOut",
  352.         Abbreviate = false
  353.     })
  354.     --===========================> Loading Data
  355.     plot1.Bern.Stopped.Value = false
  356.     plot1.CompressorParts.holder.BillboardGui.TextLabel.Text = self.plr.Values.Process.Value
  357.     plot1.CompressorParts.ye.BillboardGui.TextLabel.Text = self.plr.Values.Storage.Value
  358.     if data.GoatsInBern then
  359.         if #data.GoatsInBern ~= 0 then
  360.             for i,v in  pairs(data.GoatsInBern)do
  361.  
  362.  
  363.  
  364.                 plot.PutGoatinBern(plot1,v,data,"Load")
  365.             end
  366.  
  367.             plot1.buttons["1Goat"].Button.BillboardGui.TextLabel.Text = "Goat +1 $"..self.plr.Values.Price.Value
  368.             plot1.buttons["6Goat"].Button.BillboardGui.TextLabel.Text = "Goat +6 $"..self.plr.Values.Price2.Value
  369.         end
  370.  
  371.     end
  372.  
  373.  
  374.  
  375.     sell:MilkToStorage(sell,"Load")
  376.     sell:StorageToProcess()
  377.     sell:ProcessToCash()
  378.    
  379.     plot1.buttons.Speed10Sell.Button.BillboardGui.Price.Text = "$"..550+(self.plr.Values.ProcessSpeed.Value-1)*1000
  380.     plot1.buttons.Speed1Sell.Button.BillboardGui.Price.Text = "$"..20+(self.plr.Values.ProcessSpeed.Value-1)*100
  381.     plot1.buttons.Speed10Sell.Button.BillboardGui.TextLabel.Text = "Speed Sell ("..self.plr.Values.ProcessSpeed.Value..")  +10"
  382.     plot1.buttons.Speed1Sell.Button.BillboardGui.TextLabel.Text = "Speed Sell ("..self.plr.Values.ProcessSpeed.Value..")  +1"
  383.     plot1.buttons.Speed10Storage.Button.BillboardGui.Price.Text = "$"..1100+(((self.plr.Values.StorageSpeed.Value-5)/10)*40)*10
  384.     plot1.buttons.Speed1Storage.Button.BillboardGui.Price.Text = "$"..20+((self.plr.Values.StorageSpeed.Value/5)*20)
  385.     plot1.buttons.Speed10Storage.Button.BillboardGui.TextLabel.Text = "Speed Processor ("..self.plr.Values.StorageSpeed.Value/5 ..")  +10"
  386.     plot1.buttons.Speed1Storage.Button.BillboardGui.TextLabel.Text = "Speed Processor ("..self.plr.Values.StorageSpeed.Value/5 ..")  +1"--]]
  387.  
  388.    
  389.  
  390.     --=======================>Events
  391.     plot1.Bern.Milks.ChildAdded:Connect(function(clone2:Model)
  392.         if clone2:IsA("Model")  then
  393.             plot1.Bern.Milks:SetAttribute("Milk",#plot1.Bern.Milks:GetChildren())
  394.             clone2:SetAttribute("Owner",self.plr.Name)
  395.  
  396.  
  397.             if #plot1.Bern.Milks:GetChildren() >= 70 then
  398.  
  399.  
  400.                 plot1.Bern.limitedMode.Value = true
  401.  
  402.  
  403.             end
  404.         end
  405.     end)
  406.  
  407.     self.plr.Values.Process.Changed:Connect(function()
  408.         if plot1.Bern.Stopped.Value then return end
  409.         plot1.CompressorParts.holder.BillboardGui.TextLabel.Text = self.plr.Values.Process.Value
  410.  
  411.  
  412.     end)
  413.  
  414.     self.plr.Values.Storage.Changed:Connect(function()
  415.         if plot1.Bern.Stopped.Value then return end
  416.         MilkNumberAnimation:SetPrefix("")
  417.         MilkNumberAnimation:Start()
  418.  
  419.     end)
  420.  
  421.  
  422.  
  423.  
  424.     zone.playerEntered:Connect(function(player)
  425.         if plot1:GetAttribute("Owner") == player.Name then
  426.  
  427.             if not deb[plot1.buttons["1Goat"].Name] then
  428.  
  429.  
  430.  
  431.                 plot.EnterZone(player,deb,plot1,plot1.buttons["1Goat"])
  432.                 if plot1.buttons["1Goat"].Button.BillboardGui.TextLabel.Text == "Free Goat" then
  433.                     plot1.Bern.RefreshingMode.Value = false
  434.  
  435.                     plot1.buttons["1Goat"].Button.BillboardGui.TextLabel.Text = "Goat +1 $"..player.Values.Price.Value
  436.                     plot1.buttons["6Goat"].Button.BillboardGui.TextLabel.Text = "Goat +6 $"..player.Values.Price2.Value
  437.                     player.leaderstats.Goat.Value += 1
  438.  
  439.                     plot.PutGoatinBern(plot1,"Normal",data,"Put")
  440.                     plot1.Bern.RefreshingMode.Value = true
  441.                 else
  442.                     if player.leaderstats.Cash.Value >= player.Values.Price.Value then
  443.                         plot1.Bern.RefreshingMode.Value = false
  444.                         player.leaderstats.Cash.Value -=  player.Values.Price.Value
  445.                         player.Values.Price.Value = math.floor(player.Values.Price.Value +20)
  446.                         player.Values.Price2.Value =  math.floor(player.Values.Price2.Value +120)
  447.                         plot1.buttons["1Goat"].Button.BillboardGui.TextLabel.Text = "Goat +1 $"..player.Values.Price.Value
  448.                         plot1.buttons["6Goat"].Button.BillboardGui.TextLabel.Text = "Goat +6 $"..player.Values.Price2.Value
  449.                         player.leaderstats.Goat.Value += 1
  450.                         plot.PutGoatinBern(plot1,"Normal",data,"Put")
  451.                         plot1.Bern.RefreshingMode.Value = true
  452.  
  453.                     end
  454.                 end
  455.                 deb[plot1.buttons["1Goat"].Name]= false
  456.             end
  457.         end
  458.     end)
  459.     zone2.playerEntered:Connect(function(player)
  460.         if plot1:GetAttribute("Owner") == player.Name then
  461.  
  462.             if not deb[plot1.buttons["6Goat"].Name] then
  463.  
  464.  
  465.                 plot.EnterZone(player,deb,plot1,plot1.buttons["6Goat"])
  466.                 if player.leaderstats.Cash.Value >= player.Values.Price2.Value then
  467.  
  468.  
  469.                     player.leaderstats.Cash.Value -=  player.Values.Price2.Value
  470.  
  471.                     plot1.Bern.RefreshingMode.Value = false
  472.                     player.leaderstats.Goat.Value += 6
  473.  
  474.                     for i = 6, 1,-1 do
  475.                         player.Values.Price.Value = math.floor(player.Values.Price.Value +20)
  476.  
  477.                         plot.PutGoatinBern(plot1,"Normal",data,"Put")
  478.                     end
  479.                     plot1.Bern.RefreshingMode.Value = true
  480.                     player.Values.Price2.Value += 720
  481.                 end
  482.  
  483.  
  484.                 plot1.buttons["6Goat"].Button.BillboardGui.TextLabel.Text = "Goat +6 $"..player.Values.Price2.Value
  485.                 plot1.buttons["1Goat"].Button.BillboardGui.TextLabel.Text = "Goat +1 $"..player.Values.Price.Value
  486.                 deb[plot1.buttons["6Goat"].Name]= false
  487.             end
  488.         end
  489.  
  490.     end)
  491.     zone3.playerEntered:Connect(function(player)
  492.         if plot1:GetAttribute("Owner") == player.Name then
  493.             if not deb[plot1["Merge Button"].Name] then
  494.  
  495.                 plot.EnterZone(player,deb,plot1,plot1["Merge Button"])
  496.                 if #plot1.Bern.Goats:GetChildren() <=0 then
  497.                     warn("No Goats at bern")
  498.                 else
  499.  
  500.  
  501.                     local tableee , merge =  plot.mergeGoats(plot.PutGoatTable(plot1))
  502.                     local tablee = plot.SortTableToHigher(tableee)
  503.                     data.GoatsInBern = {}
  504.                     if merge then
  505.                         for i,v in ipairs(tablee)do
  506.                             plot.PutGoatinBern(plot1,v,data,"Put")
  507.                         end
  508.                     end
  509.                 end
  510.                 deb[plot1["Merge Button"].Name] = false
  511.             end
  512.         end
  513.     end)
  514.     zone4.playerEntered:Connect(function(player)
  515.         if plot1:GetAttribute("Owner") == player.Name then
  516.             if not deb[plot1["Sell Button"].Name] then
  517.                 plot.EnterZone(player,deb,plot1,plot1["Sell Button"])
  518.                 if  player.leaderstats.Milk.Value > 0 then
  519.                     sell:MilkToStorage(sell,"any",data)
  520.                 end
  521.                 deb[plot1["Sell Button"].Name] = false
  522.             end
  523.         end
  524.  
  525.     end)
  526.  
  527.     sell1.playerEntered:Connect(function(player)
  528.         if plot1:GetAttribute("Owner") == player.Name then
  529.             if not deb[plot1.buttons.Speed1Sell.Name] then
  530.                 deb[plot1.buttons.Speed1Sell.Name] = true
  531.  
  532.                 plot.EnterZone(player,deb,plot1,plot1.buttons.Speed1Sell)
  533.                 local price = string.gsub(plot1.buttons.Speed1Sell.Button.BillboardGui.Price.Text, "%p", "")
  534.                 if self.plr.leaderstats.Cash.Value>= tonumber(price) then
  535.                     self.plr.leaderstats.Cash.Value -= tonumber(price)
  536.                     self.plr.Values.ProcessSpeed.Value += 1
  537.                     plot1.buttons.Speed10Sell.Button.BillboardGui.Price.Text = "$"..550+(self.plr.Values.ProcessSpeed.Value-1)*1000
  538.                     plot1.buttons.Speed1Sell.Button.BillboardGui.Price.Text = "$"..20+(self.plr.Values.ProcessSpeed.Value-1)*100
  539.                     plot1.buttons.Speed10Sell.Button.BillboardGui.TextLabel.Text = "Speed Sell ("..self.plr.Values.ProcessSpeed.Value..")  +10"
  540.                     plot1.buttons.Speed1Sell.Button.BillboardGui.TextLabel.Text = "Speed Sell ("..self.plr.Values.ProcessSpeed.Value..")  +1"
  541.                 end
  542.                 deb[plot1.buttons.Speed1Sell.Name] = false
  543.             end
  544.         end
  545.     end)
  546.     sell10.playerEntered:Connect(function(player)
  547.         if plot1:GetAttribute("Owner") == player.Name then
  548.             if not deb[plot1.buttons.Speed10Sell.Name] then
  549.                 deb[plot1.buttons.Speed10Sell.Name]= true
  550.                 plot.EnterZone(player,deb,plot1,plot1.buttons.Speed10Sell)
  551.                 local price = string.gsub(plot1.buttons.Speed10Sell.Button.BillboardGui.Price.Text, "%p", "")
  552.                 if self.plr.leaderstats.Cash.Value>= tonumber(price) then
  553.                     self.plr.leaderstats.Cash.Value -= tonumber(price)
  554.                     self.plr.Values.ProcessSpeed.Value += 10
  555.                     plot1.buttons.Speed10Sell.Button.BillboardGui.Price.Text = "$"..550+(self.plr.Values.ProcessSpeed.Value-1)*1000
  556.                     plot1.buttons.Speed1Sell.Button.BillboardGui.Price.Text = "$"..20+(self.plr.Values.ProcessSpeed.Value-1)*100
  557.                     plot1.buttons.Speed10Sell.Button.BillboardGui.TextLabel.Text = "Speed Sell ("..self.plr.Values.ProcessSpeed.Value..")  +10"
  558.                     plot1.buttons.Speed1Sell.Button.BillboardGui.TextLabel.Text = "Speed Sell ("..self.plr.Values.ProcessSpeed.Value..")  +1"
  559.                 end
  560.                 deb[plot1.buttons.Speed10Sell.Name] = false
  561.             end
  562.         end
  563.     end)
  564.     procces1.playerEntered:Connect(function(player)
  565.         if plot1:GetAttribute("Owner") == player.Name then
  566.             if not deb[plot1.buttons.Speed1Storage.Name] then
  567.                 deb[plot1.buttons.Speed1Storage.Name] = true
  568.                 local price = string.gsub(plot1.buttons.Speed1Storage.Button.BillboardGui.Price.Text, "%p", "")
  569.                 plot.EnterZone(player,deb,plot1,plot1.buttons.Speed1Storage)
  570.                 if self.plr.leaderstats.Cash.Value>= tonumber(price) then
  571.                     self.plr.leaderstats.Cash.Value -= tonumber(price)
  572.                     self.plr.Values.StorageSpeed.Value += 5
  573.                     plot1.buttons.Speed10Storage.Button.BillboardGui.Price.Text = "$"..1100+(((self.plr.Values.StorageSpeed.Value-5)/10)*40)*10
  574.                     plot1.buttons.Speed1Storage.Button.BillboardGui.Price.Text = "$"..20+((self.plr.Values.StorageSpeed.Value/5)*20)
  575.                     plot1.buttons.Speed10Storage.Button.BillboardGui.TextLabel.Text = "Speed Processor ("..self.plr.Values.StorageSpeed.Value/5 ..")  +10"
  576.                     plot1.buttons.Speed1Storage.Button.BillboardGui.TextLabel.Text = "Speed Processor ("..self.plr.Values.StorageSpeed.Value/5 ..")  +1"
  577.                 end
  578.                 deb[plot1.buttons.Speed1Storage.Name] = false
  579.  
  580.             end
  581.         end
  582.     end)
  583.  
  584.     procces10.playerEntered:Connect(function(player)
  585.         if plot1:GetAttribute("Owner") == player.Name then
  586.             if not deb[plot1.buttons.Speed10Storage.Name] then
  587.                 deb[plot1.buttons.Speed10Storage.Name] = true
  588.                 local price = string.gsub(plot1.buttons.Speed10Storage.Button.BillboardGui.Price.Text, "%p", "")
  589.                 plot.EnterZone(player,deb,plot1,plot1.buttons.Speed10Storage)
  590.                 if self.plr.leaderstats.Cash.Value>= tonumber(price) then
  591.                     self.plr.leaderstats.Cash.Value -= tonumber(price)
  592.                     self.plr.Values.StorageSpeed.Value += 10 *5
  593.                    
  594.                     plot1.buttons.Speed10Storage.Button.BillboardGui.Price.Text = "$"..1100+((self.plr.Values.StorageSpeed.Value-5)/10)*40*10
  595.                     plot1.buttons.Speed1Storage.Button.BillboardGui.Price.Text = "$"..20+((self.plr.Values.StorageSpeed.Value-5)/10)*40
  596.                     plot1.buttons.Speed10Storage.Button.BillboardGui.TextLabel.Text = "Speed Processor ("..self.plr.Values.StorageSpeed.Value/5 ..")  +10"
  597.                     plot1.buttons.Speed1Storage.Button.BillboardGui.TextLabel.Text = "Speed Processor ("..self.plr.Values.StorageSpeed.Value/5 ..")  +1"
  598.                 end
  599.  
  600.  
  601.                 deb[plot1.buttons.Speed10Storage.Name] = false
  602.             end
  603.         end
  604.     end)
  605. end
  606.  
  607. function plot.ClearPlotOnPlayerLeave(plr)
  608.    
  609.     for i,v in pairs(workspace.Plots:GetChildren())do
  610.         if v:IsA("Model") then
  611.             if v:GetAttribute("Owner") == plr.Name then
  612.                 v.Bern.Stopped.Value = true
  613.                 for l,m:BasePart in pairs(v:GetDescendants())do
  614.                     if m:IsA("BasePart") then
  615.                         m.Transparency = 1
  616.                     end
  617.                 end
  618.                 for l,m in pairs(v.Bern.Milks:GetChildren())do
  619.                     m:SetAttribute("Amount",0)
  620.                     m:Destroy()
  621.                 end
  622.                
  623.                 local clone = game.ServerStorage.Storage.temp:Clone()
  624.                 clone.Parent = workspace.Plots
  625.                 clone.Name = v.Name
  626.                 clone:SetPrimaryPartCFrame(v:GetPrimaryPartCFrame())
  627.                 v.Parent = workspace
  628.                 clone.Bern.Stopped.Value =true
  629.                 wait(1)
  630.                 v:Destroy()
  631.             end
  632.         end
  633.     end
  634. end
  635.  
  636.  
  637. return plot
  638.  
  639.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement