What do you want to achieve?
I want to create the same effect treelands has for generating fruit. Some fruit would only spawn at night while other would spawn only or both. For example Apples would spawn both day and night but only on AppleTree model. These models are located in a folder on the workspace
What is the issue?
I don’t know how to go about creating this. I need to know where to start and how it should be setup. I’m fairly new to advanced scripting
What solutions have you tried so far?
I’ve tried searching for a solution but no luck. As I mentioned earlier “I don’t know how to go about creating this” so I haven’t tried anything
Where the tree is located
Any help is very much appreciated💙!
Apologies if I don’t reply fast may be busy.
use a for i, v in pairs(FruitLocations) do and then a while wait(5) do loop to create a new loop for each tree. Use math.random(0,5) to do rng for spawning. If the math.random is equal to 0, spawn a fruit.
To implement day/night spawning, use greater than or less than based on when you want the fruit to spawn on the property of Lighting that determines time.
Use Instance.new("Folder") and parent it to the tree to make a new fruit folder.
Consider adding a MaxFruit property and make sure the # of fruits in the tree has not already exceeded that before spawning a fruit (#Folder:GetChildren() to get the amount of fruits on the tree)
The fruits in TreeLands are MeshParts. Use a ClickDetector and unparent the fruits from the trees fruit folder and make a new tool in the player that clicked the fruit. Put the mesh of the fruit in the tool, name it Handle, and unanchor it. The player will then be able to pick fruit from trees.
This is what I made going based on what you said but I’m not fully understanding. This is a normal Script in ServerScriptService.
local FruitLocations = game.Workspace.FruitLocations:GetChildren()
local FruitMesh = game.ReplicatedStorage.FruitModels.Apple
for i, v in pairs(FruitLocations) do
local FruitFolder = Instance.new("Folder")
FruitFolder.Parent = v
FruitFolder.Name = "FruitFolder"
while wait(5) do
local RNGSpawn = math.random(0,5)
if RNGSpawn == 0 then
-- Spawn Fruit
FruitMesh:Clone()
end
end
end
Is this somewhat of what you were meaning?
I don’t really know what else to do