This is the result.
What do your straight left and right pieces look like? This could be the expected result… Make sure your primary parts all have the same orientation.
All pieces orientation is set to 0, 0, 0.
Could you show individually what your models look like?
I was able to fix it by changing -90 to 90 and 90 to -90. Due to how CFrames work, 90 degrees is to the left. This fixes the problem:
When used with these pieces:
Code:
local Track = game.ServerStorage.Track
local Position = CFrame.new(0,0,0)
for i = 0, 100 do
local items = Track:GetChildren()
local TrackPart = items[math.random(1, #items)]:Clone()
TrackPart.Parent = game.Workspace
TrackPart:SetPrimaryPartCFrame(Position)
if TrackPart.Name == "Left" then
Position = Position - (Position.rightVector * 25)
Position = Position*CFrame.Angles(0, math.rad(90), 0)
end
if TrackPart.Name == "Right" then
Position = Position + (Position.rightVector * 25)
Position = Position*CFrame.Angles(0, math.rad(-90), 0)
end
if TrackPart.Name == "Straight" then
Position = Position + (Position.lookVector * 25)
end
print(Position)
wait(1)
end
However, it can still collide with itself, so be wary of that. Hope I could help!
If you want to download the demo: ScriptingSupport460308 - Temple run tile generation.rbxl (18.5 KB)
I can’t open your file for some reason (probably a issue on my side). And it dosen’t spawn correctly.
I don’t know what the issue is. Is the rotation of the model suposed to be based on the x axis or should i change that?
Something is wrong with your models, try making them out of one part and see if that works first.