BackRBLX

RoDevs showcase independent

Aug 20th, 2025
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.90 KB | None | 0 0
  1. --!nonstrict
  2.  
  3. local rs = game.ReplicatedStorage
  4. local plrs = game.Players
  5. local debris = game:GetService("Debris")
  6.  
  7. local set_farming = workspace:WaitForChild("SetFarming")
  8. local dropspot = workspace:WaitForChild("Dropspot")
  9. local plants = rs.Plants
  10. local pricesntaxes = require(rs.PricesnTaxes)
  11.  
  12. local plant_waiting_time = 1
  13.  
  14. local function IsInside(pos, part)
  15.     local p = part.CFrame:PointToObjectSpace(pos)
  16.     local s = part.Size / 2
  17.     return math.abs(p.X) <= s.X and math.abs(p.Y) <= s.Y and math.abs(p.Z) <= s.Z
  18. end
  19.  
  20. local inventory_scalas = {
  21.     ["1"] = 20
  22. }
  23.  
  24.  
  25. local list_plants = {"Rice"}
  26. plrs.PlayerAdded:Connect(function(plr:Player)
  27.     local folder = Instance.new("Folder",plr)
  28.     folder.Name = "Plants"
  29.    
  30.     local money = Instance.new("NumberValue",plr)
  31.     money.Name = "Cash"
  32.    
  33.     local owned_area = Instance.new("ObjectValue",plr)
  34.     owned_area.Name = "owned_area"
  35.    
  36.     for i, plant in pairs(list_plants) do
  37.         folder:SetAttribute(plant,0)
  38.     end
  39.    
  40.     plr.CharacterAdded:Connect(function(char)
  41.         char:SetAttribute("harvested",0)
  42.         char:SetAttribute("earned",0)
  43.         char:SetAttribute("inventory",1)
  44.        
  45.         char:GetAttributeChangedSignal("harvested"):Connect(function()
  46.             if not char:FindFirstChild("inventory") then print("returned!") return end
  47.             local inventory = char:FindFirstChild("inventory") :: Model
  48.             local harvested = char:GetAttribute("harvested")
  49.             local max_inventory = inventory_scalas[tostring(char:GetAttribute("inventory"))]
  50.            
  51.             for i = 1, 4 do
  52.                 local part = inventory:FindFirstChild(tostring(i))
  53.                 if part then
  54.                     local threshold if i == 1 then threshold = 1 else threshold = (i / 4) * max_inventory end
  55.  
  56.                     if harvested >= threshold then
  57.                         part.Transparency = 0
  58.                         part.Effect.Enabled = true
  59.                     else
  60.                         part.Transparency = 1
  61.                         part.Effect.Enabled = false
  62.                     end
  63.                 end
  64.             end
  65.            
  66.         end)
  67.     end)
  68. end)
  69.  
  70. plrs.PlayerRemoving:Connect(function(plr:Player)
  71.     if plr.owned_area.Value ~= nil then
  72.         local area = plr.owned_area.Value
  73.         area.Owner.Value = nil
  74.         area.Plants:ClearAllChildren()
  75.     end
  76. end)
  77.  
  78. local debounce = true
  79. dropspot.Touched:Connect(function(part)
  80.     if not debounce then return end
  81.    
  82.     if part.Parent:FindFirstChildOfClass("Humanoid") then
  83.         local char = part.Parent
  84.         local plr = nil
  85.  
  86.         if plrs:GetPlayerFromCharacter(char) ~= nil then
  87.             plr = plrs:GetPlayerFromCharacter(char)
  88.         end
  89.  
  90.         if plr ~= nil then
  91.             debounce = false
  92.             if not char:FindFirstChild("inventory") or char:GetAttribute("earned")<=0 then debounce = true return end
  93.  
  94.             local inv = char:FindFirstChild("inventory")
  95.             for i=4,1,-1 do
  96.                 inv[tostring(i)].Transparency = 1
  97.                 inv[tostring(i)].Effect.Enabled = false
  98.                 task.wait(.1)
  99.             end
  100.             plr.Cash.Value+=char:GetAttribute("earned")
  101.             rs.NotifMoney:FireClient(plr,char:GetAttribute("earned"))
  102.            
  103.             char:SetAttribute("earned",0)
  104.             char:SetAttribute("harvested",0)
  105.             --inv:Destroy()
  106.            
  107.             --if char:FindFirstChild("Sickle") then char["Sickle"]:Destroy() end
  108.             --if plr.Backpack:FindFirstChild("Sickle") then plr.Backpack["Sickle"]:Destroy() end
  109.             debounce = true
  110.         end
  111.     end
  112. end)
  113.  
  114. set_farming.Touched:Connect(function(part)
  115.     if part.Parent:FindFirstChildOfClass("Humanoid") then
  116.         local char = part.Parent
  117.         local plr = nil
  118.        
  119.         if plrs:GetPlayerFromCharacter(char) ~= nil then
  120.             plr = plrs:GetPlayerFromCharacter(char)
  121.         end
  122.        
  123.         if plr ~= nil then
  124.             if plr.Backpack:FindFirstChild("Sickle") or char:FindFirstChild("Sickle") then return end
  125.             if not char:FindFirstChild("HumanoidRootPart") then return end
  126.            
  127.             local inv = rs.Plants[char:GetAttribute("inventory").."inventory"]:Clone()::Model
  128.             inv.Parent = char
  129.             inv.Name = "inventory"
  130.             inv:PivotTo(char.HumanoidRootPart.CFrame)
  131.             local weld = Instance.new("Weld",inv.Middle)
  132.             weld.Part0 = char.UpperTorso
  133.             weld.Part1 = inv.Middle
  134.            
  135.             rs.Plants.Sickle:Clone().Parent = plr.Backpack
  136.         end
  137.     end
  138. end)
  139.  
  140. plants.Plant.OnServerEvent:Connect(function(plr:Player,position:Vector3,plant,remaining:NumberValue)
  141.     local char = plr.Character:FindFirstChild("HumanoidRootPart")
  142.     if char == nil then return end
  143.    
  144.     local can_plant = true
  145.     local owned_area = nil
  146.     local get_exact_pos = Vector3.new(position.X,49.7,position.Z)
  147.    
  148.     for _,area in pairs(workspace.FarmAreas:GetChildren()) do if area.Owner.Value == plr then owned_area = area end end
  149.    
  150.     if owned_area==nil then can_plant = false end
  151.     if owned_area ~= nil then if not IsInside(get_exact_pos,owned_area) then can_plant = false end end
  152.     if remaining.Value <= 0 then can_plant = false end
  153.    
  154.     if not can_plant then return end -- tüm koşullar tamam
  155.    
  156.     remaining.Value-=1
  157.     if remaining.Value<=0 then
  158.         char.Parent["Humanoid"]:UnequipTools()
  159.         task.wait(.25)
  160.         remaining.Parent:Destroy()
  161.     end
  162.    
  163.     local plant_stage1 = rs.Plants:FindFirstChild(plant)["1STAGE"]:Clone() :: Model
  164.     plant_stage1:PivotTo(CFrame.new(get_exact_pos))
  165.     plant_stage1.Parent = owned_area["Plants"]
  166.    
  167.     plant_stage1:SetAttribute("wait",plant_waiting_time/4)
  168.     plant_stage1:SetAttribute("stage",1)
  169.     plant_stage1:SetAttribute("area",owned_area.Name)
  170.     plant_stage1:SetAttribute("type",plant)
  171. end)
  172.  
  173. -- areas handle
  174.  
  175. task.wait(5)
  176.  
  177. rs.Purchase.OnServerEvent:Connect(function(plr,p_type,area)
  178.     if p_type ~= "land" then return end
  179.     if area.Owner.Value ~= nil or plr.owned_area.Value ~= nil then return end
  180.    
  181.     local taxes=0 for _,tax in pairs(pricesntaxes["land"].tax) do taxes+=rs.Rules.Tax[tax].Value end
  182.     local estimated_price = pricesntaxes["land"].price+((pricesntaxes["land"].price*taxes)/100) warn("calculated tax = ",((pricesntaxes["land"].price*taxes)/100))
  183.    
  184.     if plr.Cash.Value < estimated_price then return end
  185.    
  186.     plr.Cash.Value-=estimated_price
  187.     plr.owned_area.Value = area
  188.     area.Owner.Value = plr
  189. end)
  190.  
  191. for _,area in pairs(workspace.FarmAreas:GetChildren()) do
  192.     local clickdetector = area.ownership.Main.trigger :: ClickDetector
  193.     local sg = area.ownership.Main.SG
  194.     local owner = area.Owner :: ObjectValue
  195.    
  196.     clickdetector.MouseClick:Connect(function(plr)
  197.         if area.Owner.Value ~= nil or plr.owned_area.Value ~= nil then return end
  198.        
  199.         rs.Purchase:FireClient(plr
  200.             ,"land"
  201.             ,"rbxassetid://97492019380655"
  202.             ,area.Name
  203.             ,"A wonderful place to grow up plants, take care of them, and sell them to earn money."
  204.             ,area
  205.         )
  206.        
  207.         warn("fired server")
  208.     end)
  209.    
  210.     owner:GetPropertyChangedSignal("Value"):Connect(function()
  211.         if owner.Value == nil then
  212.             sg.Frame.Image.Visible = false
  213.             sg.Frame.Displayname.Visible = false
  214.             sg.Frame.Realname.Visible = false
  215.            
  216.             sg.Frame.vacant.Visible = true
  217.         else
  218.             sg.Frame.Image.Visible = true
  219.             sg.Frame.Displayname.Visible = true
  220.             sg.Frame.Realname.Visible = true
  221.  
  222.             sg.Frame.vacant.Visible = false
  223.            
  224.             sg.Frame.Image.Image = plrs:GetUserThumbnailAsync(owner.Value.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420)
  225.             sg.Frame.Displayname.Text = owner.Value.DisplayName
  226.             sg.Frame.Realname.Text = owner.Value.Name
  227.         end
  228.     end)
  229. end
  230.  
  231. while task.wait(1) do
  232.     for _, area in pairs(workspace.FarmAreas:GetChildren()) do
  233.         local folder = area.Plants
  234.        
  235.         for _, plant:Model in pairs(folder:GetChildren()) do
  236.             if plant:GetAttribute("wait") <= 0 and plant.Name~="4STAGE" then
  237.                 print(plant:GetAttribute("type"))
  238.                 local stager = rs.Plants:FindFirstChild(plant:GetAttribute("type"))[tostring(plant:GetAttribute("stage")+1).."STAGE"]:Clone() :: Model
  239.                 stager:PivotTo(plant.Center.CFrame * CFrame.Angles(0, math.rad(math.random(360)), 0))
  240.                 stager.Parent = workspace.FarmAreas:FindFirstChild(plant:GetAttribute("area")).Plants
  241.                
  242.                 stager:SetAttribute("wait",plant_waiting_time/4)
  243.                 stager:SetAttribute("stage",plant:GetAttribute("stage")+1)
  244.                 stager:SetAttribute("area",plant:GetAttribute("area"))
  245.                 stager:SetAttribute("type",plant:GetAttribute("type"))
  246.                
  247.                 debris:AddItem(plant,0)
  248.             elseif plant.Name~="4STAGE" then
  249.                 plant:SetAttribute("wait",plant:GetAttribute("wait")-1)
  250.             end
  251.         end
  252.     end
  253. end
Advertisement
Add Comment
Please, Sign In to add comment