ContextActionService just seems to not be working for me, and I can’t figure out how to fix it! Here’s the script:
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local CAMERA_DEPTH = 24
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local function updateCamera()
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local cameraPosition = Vector3.new(rootPart.Position.X, rootPart.Position.Y + 5, rootPart.Position.Z - CAMERA_DEPTH)
camera.CFrame = CFrame.lookAt(cameraPosition, rootPart.Position)
end
local function scrollIn(actionName, inputState)
print("attemptIn")
if actionName == "scrollIn" and inputState == Enum.UserInputState.Begin then
if CAMERA_DEPTH > 2 then
CAMERA_DEPTH -= 1
print("in")
end
end
end
local function scrollOut(actionName, inputState)
print("attemptOut")
if actionName == "scrollOut" and inputState == Enum.UserInputState.Begin then
if CAMERA_DEPTH < 24 then
CAMERA_DEPTH += 1
print("out")
end
end
end
ContextActionService:BindAction("scrollIn", scrollIn, false, Enum.KeyCode.I)
ContextActionService:BindAction("scrollOut", scrollOut, false, Enum.KeyCode.O)
RunService.RenderStepped:Connect(updateCamera)