Hi,
So far, I have created a function which generates a model (corridor) and depending on the value in the function parameters, either attaches it on the front of the existing corridor piece or the back piece.
The idea is to have an infinite corridor which goes both ways (forwards and backwards), and I was wondering what the best way would be to do this (it only needs to render the corridors locally).
For detecting what corridor the player is in, I have tried using the Touched event on the players foot or on their leg if its an R6 rig. Even though it works, I’m not entirely sure if that’s the most optimal method to use.
For telling the game where to generate the corridors, so far I have tried using :Dot on the players head front vector and the corridors wall front vector (the game is first person only). I have also tried using the magnitude the player is away from the front of the corridor to determine whether they are at the front of the corridor, or the back of the corridor.
For the deletion of the corridors, I was thinking of using a for loop to gather all corridor segments and use magnitude on a part to detect the distance, then do ‘if magnitude > (insert distance here) then’ to remove segments which are far away.
I am wondering what would be the best ways to:
- detect which corridor segment the player is in
- what method I should use to tell where the corridor should generate (e.g front or back)
- what the indication should be to delete the corridor segments
Here’s what I have so far as a base:
local char = script.Parent
local plr = game.Players.LocalPlayer
local head = char.Head
local scpspawns = 0
local area = workspace['479']
local function new479(area,front)
local clone = area:Clone()
local floor = area.floor
local fsize = floor.Size
clone.Parent = workspace
scpspawns = scpspawns + 1
if front == true then
clone:SetPrimaryPartCFrame(clone.floor.CFrame * CFrame.new(0,0,fsize.Z) ) -- add to front
else
clone:SetPrimaryPartCFrame(clone.floor.CFrame * CFrame.new(0,0,-fsize.Z) ) -- add to back
end
return clone
end
I feel like I’m probably overcomplicating it due to there being so many different ways to do it, so please leave suggestions on how to approach this, or if there’s anything that I should change in the scripts current stage.
If you’d like me to clarify anything please reply with your question and I will answer it.
Thanks