Help needed with automaticly spawning bear

1 usually if i say:‘automaticly generated’ it should be clear that i need it for the whole baseplate.

  1. if you were not so sure how big the radius should of been you could of just asked then putting something random and then acting offended.
1 Like

ok sorry Ask Me Anything

my head just hurts from these scripts u know

1 Like

Its alright, i have those times to.

1 Like

I imported you suggestion into script but then get.

local AnimalFolder = game.ServerStorage.Animals
local bear: Model = AnimalFolder.Bear
local function CreateNewPart()
	local NewBear = bear:Clone(20)
	NewBear.Parent = workspace
	local BearsPosition = Vector3.new((-game.Workspace.Baseplate.Size.X / 2), game.Workspace.Baseplate.Size.X / 2) math.Random((-game.Workspace.Baseplate.Size.Z / 2), game.Workspace.Baseplate.Size.Z / 2)
	NewBear:PivotTo(CFrame.new(BearsPosition))
end
CreateNewPart()
1 Like
local AnimalFolder = game.ServerStorage.Animals
local bear = AnimalFolder.Bear

local destroyTime = 15 -- How much we wait till we delete the bear
local waitDelay = 3 -- The spawner wait value


if game.Workspace.Baseplate == nil then -- Check if the baseplate exist
	return
end


local function CreateNewPart()
	local NewBear = bear:Clone()
	NewBear.Parent = workspace
	local newCFrame = CFrame.new((math.random((-game.Workspace.Baseplate.Size.X / 2), (game.Workspace.Baseplate.Size.X / 2))), 16, (math.random((-game.Workspace.Baseplate.Size.Z / 2), (game.Workspace.Baseplate.Size.Z / 2))))
	NewBear:PivotTo(newCFrame)

	game.Debris:AddItem(NewBear, destroyTime)
end

while true do
	CreateNewPart()

	task.wait(3)
end
1 Like

do you know how to decrease the Y axis? if so please let me know and then ill do it myself since my bears are floating like they being possesed or somthing. you prob cant since you dont know how big my bears are

1 Like

this should work

local AnimalFolder = game.ServerStorage.Animals
local bear: Model = AnimalFolder.Bear
local function CreateNewPart()
    local NewBear = bear:Clone()
    NewBear.Parent = workspace
    local Baseplate = workspace.Baseplate
    local BearsPosition = Vector3.new(math.random(- 
    Baseplate.Size.X,Baseplate.Size.X),5,math.random(-Baseplate.Size.Z,Baseplate.Size.Z))
    NewBear:PivotTo(CFrame.new(BearsPosition))
end
--Test
CreateNewPart()
2 Likes

the 16 in the vector3.new is what you want to change

1 Like

alright thank you
(--------------------------------------------)

1 Like

thank you all for the support. Pro_bacon thanks for also trying to help!
i would like to help you in the future if i can.

1 Like

how did you clone them multiple times btw?

1 Like

a for loop.

for i = 1, 10 do
--do whatever
end

replace 10 with how many times

1 Like

this will spawn multiple while waiting time

while wait(time) do
--FUNCTION HERE
end
1 Like

It depends, if you want em to runs infinitely, runs it through while true do loops.

If you got a specified amount of bear you want to spawn, use

local amount = 16

for I = 1, amount do
    CreateNewPart()
end
1 Like

alright thanks ill try to make it so bears only are in the map at 50 and if its over 50 then the cloning stops. tysm for the help

1 Like

Please note there is the game.Debris function that exist in CreateNewPart() functions. YOu perhaps want t to remove that code if you want the bear to stay longer and only get destroyed when you need to. For example, the bear died and etc

Time = 1 --time until new bear spawns
Amount = 0 --Dont change
while wait(Time) do
    if Amount == 50 then
        break
    end
    CreateNewPart()
    Amount += 1
end

wait the code you gave works absolutely fine but its overlapping the amount of bears i want.

local AnimalFolder = game.ServerStorage.Animals
local bear = AnimalFolder.Bear

local destroyTime = 600
local waitDelay = 60


if game.Workspace.Baseplate == nil then -- Check if the baseplate exist
	return
end


local function CreateNewPart()
	local NewBear = bear:Clone()
	NewBear.Parent = workspace
	local newCFrame = CFrame.new((math.random((-game.Workspace.Baseplate.Size.X / 2), (game.Workspace.Baseplate.Size.X / 2))), 8, (math.random((-game.Workspace.Baseplate.Size.Z / 2), (game.Workspace.Baseplate.Size.Z / 2))))
	NewBear:PivotTo(newCFrame)

	game.Debris:AddItem(NewBear, destroyTime)
end

while true do
	CreateNewPart()

	task.wait(3)
end

is the bear not supposed to cap at 10 and then delete and spawn a new one?

1 Like

btw i did 10 for a example to look if it worked. i did not want to wait till 50.

1 Like