Flying script not working

Hi i made this flight scirpt but its not working can someone help me fix it
theres nothing in the output

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local flying = false
local flightSpeed = 50 -- Speed of flying
local camera = workspace.CurrentCamera

-- Function to toggle flying
local function toggleFlying()
	flying = not flying
	if flying then
		humanoid.PlatformStand = true -- Disable character's movement controls
	else
		humanoid.PlatformStand = false -- Re-enable character's movement controls
	end
end

-- Function to handle movement and levitation
local function onInputChanged(input)
	if flying then
		local lookVector = camera.CFrame.LookVector

		-- Check if looking up and moving
		if lookVector.Y > 0 and humanoid.MoveDirection.Magnitude > 0 then
			character:TranslateBy(lookVector * flightSpeed * 0.1)
			character:TranslateBy(Vector3.new(0, flightSpeed * 0.1, 0)) -- Fly up
		elseif lookVector.Y <= 0 then
			-- If looking down, stop flying
			flying = false
			humanoid.PlatformStand = false -- Re-enable character's movement controls
		end
	end
end

-- Key press detection
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then return end
	if input.KeyCode == Enum.KeyCode.Space then
		toggleFlying() -- Toggle flying on spacebar press
	end
end)

-- Connect input changes
UserInputService.InputChanged:Connect(onInputChanged)

-- Reset character on respawn
local function onCharacterAdded(newCharacter)
	character = newCharacter
	humanoid = character:WaitForChild("Humanoid")
end

player.CharacterAdded:Connect(onCharacterAdded)