I'm new to coding in roblox studio, and as a beginner project I decided to make an apple tree with apples growing and falling off of the tree. I put parts all around the tree to work as 'Apple Spawns'. I made a script that in 3 second intervals, randomly chooses an Apple Spawn, and adds a value of 1 to it. Once the apple spawn reaches 5, I want an apple to appear right at the spot of the apple spawn. Only problem is I don't know how to do so. I thought maybe if i can find a way to get the Vector3.p of the apple spawn, and paste it into an apple, I could get the results I wanted. Except I don't know how. Maybe I am just overthinking it and there is some perfect command or function that does this normally. I'm not asking for you to do the script for me, I just want to be pointed in the right direction. The script is below, feel free to tell me if its horrible or not. Just remember I am a beginner.
FruitSpawnScript
`FruitSpawn = script.Spawn:GetChildren(">5")[math.random(1)]
FruitSpawnPosition = FruitSpawn Vector3 --???
FruitLocation = FruitSpawn Vector3 CFrame.p()--???
Apple = script.Apple:Clone()
function AppleSpawn()
if FruitSpawn[math.random(1)] >= 5 then
Apple:MoveTo(FruitLocation)--???
wait(3)
Apple.Anchored = false
else
wait(1)
end
end
AppleSpawn()`
FruitGrowthScript
`FruitSpawn = script.Parent:GetChildren("Part")[math.random(1)]
function FruitGrowth()
FruitSpawn = FruitSpawn + 1
wait(1)
if FruitSpawn > 10 then
FruitSpawn = FruitSpawn - 5
wait(1)
end
end
`

1 comment
:MoveTo(vector3) -- see roblox wiki for more info