So this is my code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local modelFolder1 = ReplicatedStorage:WaitForChild("Stage1")
local modelFolder2 = ReplicatedStorage:WaitForChild("Stage2")
local function choseModels1()
local models1 = modelFolder1:GetChildren()
if #models1 == 0 then
warn("Error")
return nil
end
local randomIndex = math.random(1, #models1)
return models1[randomIndex]
end
local selectedModel1 = choseModels1()
if selectedModel1 then
local clone = selectedModel1:Clone()
clone.Parent = game.Workspace
clone:SetPrimaryPartCFrame(CFrame.new(6, 0.5, 9))
end
local function chooseModels2()
local models2 = modelFolder2:GetChildren()
if #models2 == 0 then
warn("Error2")
return nil
end
if selectedModel1.Name == "Incorrect" then
warn("Error3")
return nil
else
local randomIndex = math.random(1, #models2)
return models2[randomIndex]
end
end
local selectedModel2 = chooseModels2()
if selectedModel2 then
local coordinates = selectedModel1.Part1.CFrame.Position
local clone = selectedModel2:Clone()
clone.Parent = game.Workspace
clone:SetPrimaryPartCFrame(CFrame.new(coordinates))
end
As you can see, the code selects models from folders inside the Replicated Storage and randomly loads one. It also has a condition: if the first one is called “Incorrect”, theres no longer load. My problem is that local coordinates = selectedModel1.Part1.CFrame.Position
doesen’t load the position correctly. I also load an image of the Replicated Storage. Hope anyone can help, ty!