How would I make this rotation loop for a placing system more efficient?
Asked by
5 years ago Edited 5 years ago
Hi, so I have been making a placing system for a game, and got stuck at rotation. After trying for a bit, I got this. But it is extremely inefficient and is very long. Any idea on how to make it more efficient?
Edit: Specifically the floor's rotation loop
Edit2: "floorRot" is a number that gets added to the model's CFrame via CFrame.Angles() whilst placing
01 | mouse.KeyDown:Connect( function (k) |
02 | if k:lower() = = "r" and script.Parent.Parent.Parent.IsPlacing.Value then |
04 | if type = = "floor" then |
09 | elseif floorRot = = 10 then |
11 | elseif floorRot = = 20 then |
13 | elseif floorRot = = 30 then |
15 | elseif floorRot = = 40 then |
17 | elseif floorRot = = 50 then |
19 | elseif floorRot = = 60 then |
21 | elseif floorRot = = 70 then |
23 | elseif floorRot = = 80 then |
25 | elseif floorRot = = 90 then |
27 | elseif floorRot = = 100 then |
29 | elseif floorRot = = 110 then |
31 | elseif floorRot = = 120 then |
33 | elseif floorRot = = 130 then |
35 | elseif floorRot = = 140 then |
37 | elseif floorRot = = 150 then |
39 | elseif floorRot = = 160 then |
41 | elseif floorRot = = 170 then |
43 | elseif floorRot = = 180 then |
45 | elseif floorRot = = - 170 then |
47 | elseif floorRot = = - 160 then |
49 | elseif floorRot = = - 150 then |
51 | elseif floorRot = = - 140 then |
53 | elseif floorRot = = - 130 then |
55 | elseif floorRot = = - 120 then |
57 | elseif floorRot = = - 110 then |
59 | elseif floorRot = = - 100 then |
61 | elseif floorRot = = - 90 then |
63 | elseif floorRot = = - 80 then |
65 | elseif floorRot = = - 70 then |
67 | elseif floorRot = = - 60 then |
69 | elseif floorRot = = - 50 then |
71 | elseif floorRot = = - 40 then |
73 | elseif floorRot = = - 30 then |
75 | elseif floorRot = = - 20 then |
77 | elseif floorRot = = - 10 then |
82 | elseif type = = "wall" then |
85 | elseif wallRot = = 90 then |
87 | elseif wallRot = = 180 then |
89 | elseif wallRot = = - 90 then |