Weird_Dood

Spiral stair generator

Dec 26th, 2023
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | Source Code | 0 0
  1. --Script made by 1WeirdDood
  2. local NumSteps = 100 -- number of steps in the staircase
  3. local StepHeight = 1 -- height of each step
  4. local StepRadius = 0 -- radius of the staircase
  5. local TurnAmount = 360 -- degrees of rotation for each step
  6. local Direction = Vector3.new(0, 1, 0)
  7.  
  8. local AnglePerStep = TurnAmount / NumSteps
  9.  
  10. for i = 1, NumSteps do
  11.     local Angle = math.rad(AnglePerStep * i)
  12.  
  13.  
  14.     local x = math.cos(Angle) * StepRadius
  15.     local y = i * StepHeight
  16.     local z = math.sin(Angle) * StepRadius
  17.  
  18.  
  19.     local Part = Instance.new("Part")
  20.     Part.Anchored = true
  21.     Part.Size = Vector3.new(5, 1, 5) -- brick size
  22.     Part.Position = Vector3.new(x, y, z)
  23.     Part.Orientation = Vector3.new(0, -AnglePerStep * (i - 1), 0)
  24.     Part.Parent = workspace
  25.    
  26.     if i > 1 then
  27.         local Weld = Instance.new("WeldConstraint")
  28.         Weld.Part0 = Part
  29.         Weld.Part1 = PreviousPart
  30.         Weld.Parent = Part
  31.     end
  32.     PreviousPart = Part
  33. end
  34.  
Advertisement
Add Comment
Please, Sign In to add comment