Is there any way I can do this?

Ok so I am making a working computer but when I load the game everything works but the screen is hard to see, is there anyway I can make it so when I click the PC my camera will zoom into it?giphy (3)

3 Likes

It might be a better idea to have it as a solid image with a ClickDetector, and once clicked it brings up the GUI on your screen. I think that would be better than trying to get the camera to zoom properly in on it.

1 Like

Ok, I might try that but is there anyway to make the zoom work?

There is, however I’m not great at camera work so someone else would have to chime in with a solution. I also can’t guarantee that the GUI will be of good quality when zoomed in or work properly on mobile.

2 Likes

You could setup a non-collidable part positioned where you want the camera to be, then in a LocalScript; create a function to change the camera’s type to Scriptable and change the Camera’s CFrame to the part’s CFrame, then fire the function with a ClickDetector.

If not sure where to start, I’d suggest looking at the documentation of ClickDetectors and CurrentCamera.

2 Likes

Could you dumb it down for me because that’s a lot of big words

Just have TweenService move the camera into the part you want.

Heres an example:

local TweenService = game:GetService("TweenService")

TweenService:Create(YourPart, TweenInfo.new(1), {CFrame = YourPart.CFrame}):Play()

oh ok thx lol, I’m new with this camera stuff.

And will it work so if I click it once it will zoom and then when i click again it would zoom out right?

i recommend you write this if you want to tween the camera

TweenService:Create(workspace.CurrentCamera, TweenInfo.new(1), {CFrame = YourPart.CFrame}):Play()

will it work so if I click it once it will zoom and then when i click again it would zoom out right?

You would have to set the CurrentCamera’s CameraType property to Scriptable before you tween it, then change it back to Fixed, but yes it would work if you click it to zoom out and in, as long as you set it that way.

You would do so by setting up a debounce and by connecting to the MouseClicked event on the clickdetector

local hasClicked = false
clickdetector.MouseClicked:Connect(function()
       if not hasClicked then
            --- zoom in code here
            hasClicked = true
            currentCamera.CameraType = Enum.CameraType.Scriptable
       else
           --- zoom out code here
           currentCamera.CameraType = Enum.CameraType.Fixed
       end
end)
3 Likes

YAY it worked thx giphy (4)

4 Likes

Hey, I’m also new to camera and I tried to follow what you guys were telling @zachary108181. I have the code that I wrote below. Any help is appreciated!

So basically just like zachary, I have a security room with lots of monitors and computers displaying security camera footage live. Its kinda hard to see what the computer and monitors are saying so I wanted for people to zoom in and out by clicking on the Screen. Here is how it looks:

local hasClicked = false

script.Parent.ClickDetector.MouseClick:Connect(function()
local TweenService = game:GetService(“TweenService”)
if not hasClicked then
— zoom in code here
print(“Zooming in”)
hasClicked = true
workspace.currentCamera.CameraType = Enum.CameraType.Scriptable
TweenService:Create(workspace.CurrentCamera, TweenInfo.new(1), {CFrame = script.Parent.CFrame}):Play()
else
— zoom out code here
print(“Zooming out”)
hasClicked = false
workspace.currentCamera.CameraType = Enum.CameraType.Fixed
end
end)

1 Like

Ok so what I had to do was make a part that’s not the screen like this


and I named it Grab.
and you need to do this
oijuhyg
now the script labeled Camera should be

local Clicky = script.Parent
local Grab = script.Parent.Parent
local event = game.ReplicatedStorage.Camera


Clicky.MouseClick:Connect(function(player)
	event:FireClient(player, Grab)
end)

now there is other things like this

the script in startercharacterscipts should be

local Clicky = script.Parent

local Grab = script.Parent.Parent
local TweenService = game:GetService(“TweenService”)
local event = game.ReplicatedStorage.Camera
local player = game.Players.LocalPlayer – added player variable to top of script

local CurrentCamera = workspace.CurrentCamera

event.OnClientEvent:Connect(function(Grab)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TI = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0)
local Goal = {CFrame = Grab.CFrame}
local Animation = TweenService:Create(CurrentCamera, TI, Goal)
Animation:Play()
Animation.Completed:Wait() – wait for tween to finish
CurrentCamera.Focus = Grab.CFrame

cancelOnMove = player.Character.Humanoid.Running:Connect(function(speed) -- save the connection to remove later
	if speed > 0 then
		CurrentCamera.CameraType = Enum.CameraType.Scriptable
		local TI = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0)
		local Goal = {CFrame = player.Character.Head.CFrame}
		local Animation = TweenService:Create(CurrentCamera, TI, Goal)
		Animation:Play()
		Animation.Completed:Wait() -- again, wait for tween
		CurrentCamera.CameraType = Enum.CameraType.Custom
		
		cancelOnMove:Disconnect() -- disconnect listener to prevent memory leaks
	end
end)

end)

(sorry I suck at explaining things but I made a model for you to look at that should help lol)

Opensource camera thing - Roblox

1 Like