Monster doesn't spawn instantly when you open the door

I’m recreating rooms but when the monsters spawn after one minuite

i don’t have screenshots, but in the output it says that has spawned but it didn’t

i didn’t find any solution to the problem because i’m using tween service to move the entity because it’s a part

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

here’s the code that spawns the entity

event.OnInvoke = function()
	--room generation stuff
	if game.ReplicatedStorage.Number.Value > 61 then
		if math.random(1,5) == 1 and not workspace:FindFirstChild("A-60") and not workspace:FindFirstChild("A-200") then
			warn("A-60 HAS SPAWNED!!!")
			coroutine.wrap(monsters.New)(game.ServerStorage.entities["A-60"]) -- calls the entity module script
		end
	end
end

then there’s the module that spawns the entities

local TweenService = game:GetService("TweenService")

local monsters = {}

function monsters.New(Model:Part)
	local entity = Model:Clone()
	entity.Parent = workspace
	entity.CFrame = workspace.start.center.CFrame
	local i = 2
	
	--coroutine.wrap(killplayers)(entity.Hitbox)
	
	while true do
		if workspace.generatedrooms["ROOM"..i] then
			local tween = TweenService:Create(entity, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {CFrame = workspace.generatedrooms:FindFirstChild("ROOM"..i).center.CFrame})
			tween:Play()
			tween.Completed:Wait()
			i += 1
			if i == game.ReplicatedStorage.Number.Value then
				entity:Destroy()
				break
			end
		end
	end
end

return monsters

ops i see what was the problem, now it’s solved, the entity was out of sight so it spawned on the server but spawned after at the position of the server

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.