Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you change the zoom in/zoom out keys?

Asked by 7 years ago
Edited 7 years ago

Have you ever played the game PSYCHOCATS in roblox? I somewhat noticed that the I and O keys weren't working and the K and L keys replaced it. Does anyone else know how to change the zoom in/zoom out keys? Part of the script:

--Define UserInputService local uis = game:GetService('UserInputService')

--Define UserInputService
local uis = game:GetService('UserInputService')


--InputBegan
uis.InputBegan:connect(function(input,process)
    --Make sure it's not a game process
    if not process then
        --Check key 'E'
        if input.KeyCode == Enum.KeyCode.I and Player.CameraMaxZoomDistance = 400 Player.CameraMaxZoomDistance = 0.5 then
            local CameraSetting
            local Player = game.Players.LocalPlayer
            Player.CameraMaxZoomDistance = 15
            Player.CameraMinZoomDistance = 5
        end
    end
end)


0
We know how to.. But theres a difference between asking for code and making an attempt and then asking for help. MessorAdmin 598 — 7y
0
@MessorAdmin: there's a difference between asking for help and asking for code. Saying "How do you do X" is not the same as "Give me a script to do X". In this case, the answer need only refer to the correct function/service/concept to satisfy the question. @MacFan2006: you should edit your original question with your script and remove your answer (since it isn't an answer). chess123mate 5873 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

There are a few methods you could use:

  1. Modify the StarterPlayerScripts's CameraScript.RootCamera. Specifically, if you run a blank place in Solo/test mode, you can open up StarterPlayer.StarterPlayerScripts and see CameraScript (and a bunch of ModuleScripts). Copy/paste all that into whatever place you want to try this out, then comment out RootCamera's lines 1017-1021 (1017 is if input.KeyCode == Enum.KeyCode.I then), or alternatively change the keys or behaviour involved (ex you could make it zoom faster/slower or use different keys to zoom).
  2. Simply restrict the camera's zoom level to whatever you want it to be (you could then change it when a user inputs certain keys, if you wanted). (Your script appears to be trying to do this.)
  3. Change the CameraType to Scriptable (but this disables all camera movement - only do this if you want to control the camera entirely on your own).

Notably, #1 does not stop you from scrolling in/out with the mouse wheel - it only prevents 'i' and 'o' from zooming in/out.

Looking at your script and assuming it's #2 that you're after, you don't need to listen to InputBegan, you just need to assign the properties to the camera. If you put the CameraMinZoomDistance to the same value as the CameraMaxZoomDistance, 'i' and 'o' won't do anything (and nor will scrolling in/out). The script as you currently have it sets the ZoomDistance only after you press 'i', and doesn't fully disable zooming in/out (though it restricts it a lot). Further, the if statement ensures that the code to set up the camera only runs once. Better would be to disconnect the event (though in this case, you don't need the event in the first place)

Ad
Log in to vote
0
Answered by 7 years ago

@MessorAdmin --Define UserInputService local uis = game:GetService('UserInputService')

--InputBegan uis.InputBegan:connect(function(input,process) --Make sure it's not a game process if not process then --Check key 'E' if input.KeyCode == Enum.KeyCode.I and Player.CameraMaxZoomDistance = 400 Player.CameraMaxZoomDistance = 0.5 then local CameraSetting local Player = game.Players.LocalPlayer Player.CameraMaxZoomDistance = 15 Player.CameraMinZoomDistance = 5 end end end)

This is the script I mean't to say.

Answer this question