So I am trying to make it where you get near a model and it rotates the part around a certain point. It works fine, but it repeats until the players magnitude is out of the limit. I tried using repeat until and if else statements but it still does not work perfectly.
local doors = workspace.Doors local humRoot = game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart", 10) while wait() do for _,v in pairs(doors:GetChildren()) do if (v.Hinge.Position - humRoot.Position).magnitude <= 15 then repeat wait() for i = 1,90 do wait() v.Part.CFrame = v.Hinge.CFrame * CFrame.Angles(0, math.rad(i), 0) * CFrame.new(2.5,0,0) end until v.Part.CFrame == v.Hinge.CFrame * CFrame.Angles(0, math.rad(90), 0) * CFrame.new(2.5,0,0) break else v.Part.CFrame = v.Hinge.CFrame * CFrame.Angles(0,0,0) * CFrame.new(2.5,0,0) end end end