For my script when I UnbindAction the move forward and backward, is there a way to bind it again. I tried bind action, but it doesn’t work
local ContextActionService = game:GetService("ContextActionService")
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
camera.CameraType = Enum.CameraType.Scriptable
local cameraDistance = 30
local cameraHeight = 0
game:GetService("RunService").RenderStepped:Connect(function()
local character = player.Character
if character and character:FindFirstChild("Humanoid") and character:FindFirstChild("HumanoidRootPart") then
local torso = character.HumanoidRootPart
local cameraPosition = Vector3.new(torso.Position.X, torso.Position.Y + cameraHeight, torso.Position.Z - cameraDistance)
if torso:FindFirstChild("FastStart") == nil then
camera.CFrame = CFrame.new(cameraPosition, torso.Position)
else
-- Lower camera for fast start
camera.CFrame = CFrame.new(cameraPosition - Vector3.new(0, 15, 0), torso.Position)
end
end
end)
local originalCameraDistance = cameraDistance
local originalCameraHeight = cameraHeight
local function toggleCameraValues()
if cameraDistance == originalCameraDistance and cameraHeight == originalCameraHeight then
cameraDistance = 0
cameraHeight = 30
ContextActionService:BindAction("moveForwardAction")
ContextActionService:BindAction("moveBackwardAction")
else
ContextActionService:UnbindAction("moveForwardAction")
ContextActionService:UnbindAction("moveBackwardAction")
cameraDistance = originalCameraDistance
cameraHeight = originalCameraHeight
end
end
UserInputService.InputBegan:Connect(function(input, isProcessed)
if isProcessed then return end
if input.KeyCode == Enum.KeyCode.F then
toggleCameraValues()
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.