Hi! I am making a menu for my game, and I was trying to make a script for the camera following the mouse. The only problem is that it affects just one camera part. I want it so that even if I tween/switch the CurrentCamera to another parts’ CFrame, the effect would still happen. How would I go about this?
local maxTilt = 12
local tweenInfo = TweenInfo.new(.1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local camera = workspace.CurrentCamera
local DefaultCFrame = game.Workspace.MainCamera
local connection = game:GetService("RunService").RenderStepped:Connect(function()
ts:Create(camera,tweenInfo,{CFrame = DefaultCFrame.CFrame * CFrame.Angles(math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),0)}):Play()
end)
With the RunService.RenderStepped you are creating hundreds of Tweens with the same values, referenced to that specific game.Workspace.MainCamera part, playing them constantly and never stopping of doing that, and each Tween its only 0.1 seconds?
Whats the camera effect you are trying to achieve? Im not sure, but I think thats not a good aproach for it.
I used the RenderStepped to manipulate the camera many times, but only manipulating the CFrame of the camera, and not adding tweens inside the RenderStepped
Something like this.
The camera follows the mouse smoothly.
Sorry for the low frame rate, I recorded this on the Roblox Recorder
More clarification. I’d like this, but with more customization. Customization being I can change the CFrame and still have the effect without having to do* multiple connections
For some questions:
I got the script from a post here, I don’t know where the post with the script is but I’ll reply right back when I find it
For the tween, the effect shown in the video only works if I make it higher, the tween in the original post/script was 0.01 I think? A smooth ‘camera follow’ only works if its like 0.1, 0.5 or higher is gonna make it slower and worse.
1 Like
Mmh… somehow Im unable to watch the video… Its only a black screen with sounds… I downladed the video but still only a black screen.
I really wanted to watch the vid, cause you say this is for a menu gui right? and the camera should follow the mouse smoothly, but I dont understand whats the purpose of the Tween
If you are using the RunService.RenderStepped, thats updating on a very fast loop, manipulating the CFrame of the camera would be enough, no need for the Tween, but, because I cant watch the video, Im not sure if a Tween is needed to create an extra effect and not only camera following the mouse.
If you want to see the effect yourself, it’s Combat Warriors. It’s the only game I know (in my knowledge) that has this effect.
What could be a better alternative for the RenderStepped loop?
I could check it later.
Meanwhile, I suggest to only manipulate the CFrame of the camera following the mouse inside the RenderStepped, and the Tween is not needed.
Thats a great alternative already, I cant remember right now which one triggers before and after the physics and the render, but you could give it a try to the other client “loops” from RunService.
I’ll try my best, I’m not a very good scripter 
Thank you! I’ll be waiting for your response 
1 Like
Hello, are you back? I apologise if you are busy.
Something I did was I just made it so that it only works for one camera only. I’ve tried using pairs but it didn’t work, I didn’t know how to specify the Camera Parts (they were in a folder).
I just disconnected the RBXScriptConnection whenever I switched to a camera. Something like:
text.Activated:Connect(function()
Camera.CFrame = CameraFolder.camera2.CFrame
connection:Disconnect() --not the full script, but this is basically what I did
end)
If I did just change the DefaultCFrame to just the CurrentCamera’s CFrame, the camera goes CRAZY. But yeah, that’s basically what I did. Waiting for you to reply 
1 Like