What do you want to achieve? Repeatedly set the position of the camera to the Aim part without the camera spinning in a circle loop.
What is the issue? When I enter the first person mode, my camera spins in a loop with no printed errors.
What solutions have you tried so far? I’ve tried switching up the code to see if it would work, I’ve searched on some topics on first person but none really have helped.
This is what the first person is planned to look like:
This is the script I have for the First person system:
UIS.InputBegan:Connect(function(key, typing)
if key.UserInputType == Enum.UserInputType.MouseButton2 and Equipped == true and typing == false then
TrueFirstPersonAim = true
TrueFirstPersonAim = true
task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
game.Players.LocalPlayer.CameraMaxZoomDistance = 0.5
repeat
task.wait(0.002)
Camera.CFrame = firearm.AimPart.CFrame
until
TrueFirstPersonAim == false
--warn(firearm.AimPart.CFrame)
Mouse.Icon = "rbxassetid://0" -- Hide cursor lol
end
end)
UIS.InputEnded:Connect(function(key, typing)
if key.UserInputType == Enum.UserInputType.MouseButton2 and Equipped == true and typing == false then
TrueFirstPersonAim = false
task.wait()
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Players.LocalPlayer.CameraMaxZoomDistance = 128
Mouse.Icon = MouseIcon
end
end)
The reason why there’s a variable named “true first person aim” is because there is 2 variants to first person, The one below and from the guns sights.
The reason why its spinning is because im using a repeat until truefirstpersonaim == false loop. But i don’t understand why it makes the camera spin so much.
If anyone has experience with Cameras and stuff, could you help me out?