How do I make a 'Seek Chase'?

Hello, I want to make a ‘Seek Chase’, like in Doors, I want to make specified rooms only spawn during the chase, and also locked rooms will not spawn during the chase, then other entities don’t spawn, only one entity spawns to chase you, and I don’t know how to make it.

Any help is appreciated, thanks.

5 Likes

What part do you need help with?

3 Likes

The entity spawning and spawning specified rooms parts.

Anyways, here is the room module script:

local TweenService = game:GetService("TweenService")

local door = require(script.Door)
local furniture = require(script.Furniture)
local item = require(script.Item)

local room = {}
room.info = require(script.RoomInfo)
room.lastTurnDirection = nil
room.random = Random.new()

function room.GetRandom(prevRoom)
	local totalRarity = 0
	for i, info in pairs(room.info) do
		totalRarity += info.Rarity
	end
	local randomRarity = room.random:NextNumber(0, totalRarity)
	local currentRarity = 0
	local randomRoom = nil
	for i, info in pairs(room.info) do
		currentRarity += info.Rarity
		if randomRarity <= currentRarity then
			randomRoom = game.ReplicatedStorage.Rooms[i]
			break
		end
	end

	local direction = room.info[randomRoom.Name]["Direction"]

	if (prevRoom.Name == randomRoom.Name)
		or (direction and direction == room.lastTurnDirection) 
	then
		return room.GetRandom(prevRoom)
	else
		if direction then
			room.lastTurnDirection = direction
		end
	return randomRoom
	end
end

function room.Generate(prevRoom, number)
	local randomRoom = room.GetRandom(prevRoom)
	local newRoom = randomRoom:Clone()

	newRoom.PrimaryPart = newRoom.Entrance
	newRoom:PivotTo(prevRoom.Exit.CFrame)
	
	local requiresKey = false
	local locations = furniture.FurnishRoom(newRoom)
	if locations then
		if room.random:NextInteger(1, 10) == 10 then
			local random = room.random:NextInteger(1, #locations)
			local randomLocation = locations[random]
			requiresKey = true
		
		    item.New(randomLocation, "Key")
		end
	end
	local newDoor = door.New(newRoom, number, requiresKey)

	newRoom.Parent = workspace.GeneratedRooms

	return newRoom
end

return room

Edit: And also the eyes of the entity spawning on the walls to see if the room that starts the chase is near, and like I mentioned, other entities don’t spawn during the chase.

2 Likes