I’m trying to create a key bind where upon pressing the I key it changes changes the view of the camera. I already disabled I and O keys for zooming but I want my own keybind that also disables zooming with the scroll.
How would I go about this?
I’m trying to create a key bind where upon pressing the I key it changes changes the view of the camera. I already disabled I and O keys for zooming but I want my own keybind that also disables zooming with the scroll.
How would I go about this?
I recently did something similar.
In a LocalScript in StarterGui, grab the CurrentCamera then make it Scriptable:
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
use UserInputService.InputBegan
like this:
game:GetService("UserInputService").InputBegan:Connect(function(key)
Then, check if the key is ‘I’. Also, create a variable for the current Camera Mode. Create an if var == 1 then var == 2, if var == 2 then var == 1 type of situation.
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
local Mode = "Default" -- Default Roblox camera.
game:GetService("UserInputService").InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.I then
if Mode == "Default" then
Mode = "TopDown"
elseif Mode == "TopDown" then
Mode = "TopDown"
end
end
end)
Somewhere else in the script, you need to access the camera.
game:GetService("RunService").RenderStepped:Connect(function()
cam.CameraSubject = hum
if currentMode == "Default" then
Camera.CameraType = Enum.CameraType.Custom
elseif currentMode == "TopDown" then
-- Your custom camera script here
end
end)
I’ll let you do the actual camera part as it’s both relatively easy & I don’t want to just give you a full script.
Hope I helped!