Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make the cframe keep increasing from its original position?

Hi! I have a script which "extends" a corridor by cloning itself and placing it on the end of the previous one. However, currently, it just pastes the corridor infront of the previous and stacks. Anyone have any ideas? Script:

while true do
	local infgen = game.Workspace:FindFirstChild("original"):Clone()
	local pos = infgen.PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) 
	wait(12)
	infgen.Name = "notorig"
	infgen:SetPrimaryPartCFrame(pos)
	wait(.4)
		infgen.Parent = game.Workspace
end

2 answers

✓ Accepted answer

Hey!

The mistake you are doing is you are always grabbing the CFrame from the original corridor, instead grabbing it from the latest created corridor.

I think this should fix it if I am not mistaken:

local AmountOfCorridors = 0 -- Add variable to define how much corridors you have cloned.

while true do
	local infgen = game.Workspace:FindFirstChild("original"):Clone()
	infgen.Name = "notorig"..AmountOfCorridors -- Creating the model, always having a number behind it (notorig1, notorig2, notorig3, and so on...)

	local pos = game:Workspace:FindFirstChild("notorig"..AmountOfCorridors).PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) -- Find the latest created corridor 

	wait(.1)

	AmountOfCorridors = AmountOfCorridors+1 -- Adding +1 because we have created a new corridor.
	infgen:SetPrimaryPartCFrame(pos)
	wait(12)
end

Let me know if this worked!

2 comments

0

mhm you got it faster than me, good job

0

I did think i had to do something like this but wasn't sure how to get around doing it, Thank you!

The code might not work, Im on mobile :p rename "original" model from workspace to "original0"

local nr = 0
while true do 
nr = nr + 1
local infgen= game.Workspace:FindFirstChild("original"..nr):Clone() 
local pos = infgen.PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) 
wait(12) 
infgen.Name = "original" ..nr
infgen:SetPrimaryPartCFrame(pos) 
wait(.4)
 infgen.Parent = game.Workspace end

Edit: it was alr answered

1 comment

0

Thanks, This is amazing! Keep up the great work! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.