This script is a system that makes the Camera (workspace.CurrentCamera) moving depending on Player:GetMouse() interactions. (As in Roblox Studio, when right-clicking your mouse, you can move your camera properly and indicate with your mouse where you want your camera to look at).
UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
if moveCam then --Determined if right click is pushed or not, in another function and is only toggled if the condition is true
UIS.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
Camera.CFrame = Camera.CFrame * CFrame.Angles(math.rad(-input.Delta.y/rotateRatio), math.rad(-input.Delta.x/rotateRatio),0) --Does change camera rotation but weirdly -ç-
else
UIS.MouseBehavior = Enum.MouseBehavior.Default
end
end
The problem is that when I am rotating the camera, it does not remain parallel to the “floor” like, I am making the camera shaking in the video and when you do that, it makes it rotate weirdly and do this upside down effec (https://gyazo.com/4f947cd449426347bb69fa333a5041f0 I don’t know if it is clearer with this one)
Ohhh! I got it now. The problem is that you are setting the Z value to 0 only once every time the mouse is being held down. You need to add a RenderStepped event after if moveCam then
You could also just put the CFrame changer in a while wait(.05) do loop
In any way you want, you need to make sure at least that “0” is looped while the mouse is being held down.
There is absolutely no problem about that ^^
Actually, I am also not that good when I have to manipulate them x)
Well, thank you to have spent a bit of your time to help me though, if you have any problem I may help you (Well, not on CFrames -) lmaoo
I talked to him on Discord and he found a solution:
local X = 0
local Y = 0
UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.Gamepad2 then
if moveCam then
UIS.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
X += input.Delta.X
Y += input.Delta.Y
Camera.CFrame = CFrame.new(Camera.CFrame.Position) * CFrame.Angles(0,math.rad(-X),0) * CFrame.Angles(math.rad(-Y),0,0)
else
UIS.MouseBehavior = Enum.MouseBehavior.Default
end
end
end)
I added something more to his script since the speed is quite fast, replace the line: