I’m trying to make an infinite elevator with different varying sections, so I’m having the script pull a randomized section out of a folder in serverstorage and moving the main part of the welded model to the designated location. I looked at a couple different posts that all said to use cframe instead of position, I did, and it still has the same result. The script moves the primarypart perfectly fine, but the other parts are still stuck.
Weld Script
local Lights = game.ServerStorage.Lights
local CloneFolder = game.ServerStorage.ShaftCloneStorage
local PipeModel = game.ServerStorage.BluePipe
for i,Section in pairs(CloneFolder:GetChildren()) do --welds all sections
for i, Part in pairs(Section:GetChildren()) do
if Part.Name ~= "Main" then
local Weld = Instance.new("WeldConstraint")
Weld.Part1 = Section.PrimaryPart
Weld.Part0 = Part
Weld.Parent = Section.PrimaryPart
print(Part)
Part.Anchored = false
end
end
end
for i, LightModel in pairs(Lights:GetChildren()) do --welds all lights
if LightModel.ClassName == "Model" then
for i,Part in pairs(LightModel:GetChildren()) do
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Lights.PrimaryPart
Weld.Part1 = Part
Weld.Parent = Lights.PrimaryPart
Part.Anchored = false
end
end
end
for i, Pipe in pairs(PipeModel:GetChildren()) do --weld pipes
if Pipe.Name ~= "Main" then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = PipeModel.PrimaryPart
Weld.Part1 = Pipe
Weld.Parent = PipeModel.PrimaryPart
Pipe.Anchored = false
end
end
Part Movement Script
(only using one section for testing purposes)
wait(1)
--Spawn Elevator Shaft
local sectionY
local pipeY --declares variable here to increase scope
for i = 1,30 do
if i == 1 then
sectionY = -8.65 --lowest spot the shaft will always be
end
local shaftClone --increase scope
local sectionSelection = math.random(1,2) --picks shaft
if sectionSelection == 1 or sectionSelection == 2 then --1/4 chance to pick the empty shaft
sectionSelection = "Section"..1 --picks section 1
sectionSelection = ShaftCloneStorage:FindFirstChild(sectionSelection)
shaftClone = sectionSelection:Clone() --clones it
print(sectionY)
shaftClone.PrimaryPart.CFrame = CFrame.new(0,sectionY,0)
shaftClone.Parent = ElevatorShaft
lightClone = LightCloneStorage:Clone()
lightClone.PrimaryPart.CFrame = CFrame.new(0,sectionY,0)
lightClone.Parent = ElevatorShaft
randomizeLightFlicker(lightClone)
end
if sectionSelection ~= "Section4" then
local pipeClone = BluePipe:Clone()
pipeClone.PrimaryPart.CFrame = CFrame.new(0,sectionY,0)
pipeClone.Parent = shaftClone
end
sectionY = sectionY + 48.9 --distance it takes to get to the next shaft position
end
primarypart is at the top