Zoom in/out camera on clicking any parts

Hello,

How do I script to zoom in any parts when you click and saying to “Zoom” the GUI?

Hello there DevForum is not a place to ask for scripts but if you need help with a script we can help out.


Anyways eventhough I want to help you I can’t really understand what you are trying to achieve in here. Can you explain it more please?

Next time please attempt before asking on the Devforum, but this API reference seems relevant to you: Camera. For example if you wanted to “zoom” in the user’s camera, you would do something like this:

-- Client Script
workspace.CurrentCamera.FieldOfView = 50

To link this up to a GuiObject like a TextButton, you would simply just bind the request for when the button is clicked.

-- Client Script, in TextButton or ImageButton
script.Parent.MouseButton1Click:Connect(function()
    workspace.CurrentCamera.FieldOfView = 50
end)

Now before I’m finished, let’s make it a toggle, so when you click the button it will zoom in, and when you click it again it goes to default zoom.

-- Client Script, in TextButton or ImageButton
local ZoomedIn = false
script.Parent.MouseButton1Click:Connect(function()
    ZoomedIn = not ZoomedIn
    workspace.CurrentCamera.FieldOfView = ZoomedIn and 50 or 70
end)

There’s more things you can do with this, like you can make the FieldOfView instead of instantly jumping to zoom and back you could make it tween with TweenService to create a smooth effect.

I hope this helps!

1 Like

Basically, you would make it so when a player clicks the gui, it changes the cameras subject to the part like this:

local isClicked
isClicked = false
script.Parent.MouseButton1Down:Connect(function()
    isClicked = not isClicked
    workspace.CurrentCamera.CameraSubject = isClicked and workspace.Part
end)

You want to make this a client script, if its a server this will not work.

At SCR game has something that is schedule trains on Screen so I’m wondering what I should really do? What should I add on part? GUIs? By steps so I may understand.