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
mouse.KeyDown:Connect(function(k)
if k:lower() == "r" and script.Parent.Parent.Parent.IsPlacing.Value then
if type then
if type == "floor" then
isRotating = true
while isRotating do
if floorRot == 0 then
floorRot = 10
elseif floorRot == 10 then
floorRot = 20
elseif floorRot == 20 then
floorRot = 30
elseif floorRot == 30 then
floorRot = 40
elseif floorRot == 40 then
floorRot = 50
elseif floorRot == 50 then
floorRot = 60
elseif floorRot == 60 then
floorRot = 70
elseif floorRot == 70 then
floorRot = 80
elseif floorRot == 80 then
floorRot = 90
elseif floorRot == 90 then
floorRot = 100
elseif floorRot == 100 then
floorRot = 110
elseif floorRot == 110 then
floorRot = 120
elseif floorRot == 120 then
floorRot = 130
elseif floorRot == 130 then
floorRot = 140
elseif floorRot == 140 then
floorRot = 150
elseif floorRot == 150 then
floorRot = 160
elseif floorRot == 160 then
floorRot = 170
elseif floorRot == 170 then
floorRot = 180
elseif floorRot == 180 then
floorRot = -170
elseif floorRot == -170 then
floorRot = -160
elseif floorRot == -160 then
floorRot = -150
elseif floorRot == -150 then
floorRot = -140
elseif floorRot == -140 then
floorRot = -130
elseif floorRot == -130 then
floorRot = -120
elseif floorRot == -120 then
floorRot = -110
elseif floorRot == -110 then
floorRot = -100
elseif floorRot == -100 then
floorRot = -90
elseif floorRot == -90 then
floorRot = -80
elseif floorRot == -80 then
floorRot = -70
elseif floorRot == -70 then
floorRot = -60
elseif floorRot == -60 then
floorRot = -50
elseif floorRot == -50 then
floorRot = -40
elseif floorRot == -40 then
floorRot = -30
elseif floorRot == -30 then
floorRot = -20
elseif floorRot == -20 then
floorRot = -10
elseif floorRot == -10 then
floorRot = 0
end
wait(0.2)
end
elseif type == "wall" then
if wallRot == 0 then
wallRot = 90
elseif wallRot == 90 then
wallRot = 180
elseif wallRot == 180 then
wallRot = -90
elseif wallRot == -90 then
wallRot = 0
end
end
end
end
end)

2 comments
Oh, sorry! I edited my answer to show what it does.
Actually I don't think it can be more efficient anyways