So essentially I have a script that spawns a healing orb every minute in my arena but I want to make it so no more will spawn if there are 2 already there.
(I have them spawn in a heal folder)
I want them to spawn at the top of this part randomly then float down to the ground but I couldn’t figure out the float down part.
In your loop that runs every however long to add a new heal you can simply add a check to get the number of objects in the folder.
loop here:
if #heals:GetChildren() >= 2 then return end
This gets all the items in the folder with :GetChildren() and then gets the total count with #, if the number it returns is greater than or equal to 2 then we can just use return to stop the loop from running for that iteration.
If you already have them spawning you can simply use TweenService to make them float down.
local tweenService = game:GetService("TweenService") -- Get TweenService
local healFloatInfo = TweenInfo.new(1) -- Change info like duration, style, and direction here
-- Create and play a tween
local healTween = tweenService:Create(healPartHere, healFloatInfo,
{CFrame = healPartHere.CFrame-Vector3.new(0,distanceToFloatDownwards,0)})
healTween:Play()
And you can use the method lolbiIlyyy said to limit the amount to 2.